﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Smartdispatch
{
    public class CtrlFun
    {
        /// <summary>
        /// 实例化对象
        /// </summary>
        public TagNameEntity tagNameEntity = new TagNameEntity();
        public WaterFactory_7 waterFactory_7 = new WaterFactory_7();
        public WaterFactory_6 waterFactory_6 = new WaterFactory_6();
        public WaterFactory_5 waterFactory_5 = new WaterFactory_5();
        public WaterFactory_2 waterFactory_2 = new WaterFactory_2();
        public Tazishan tazishan = new Tazishan();
        public HongHe hongHe = new HongHe();
        public FengHuang fengHuang = new FengHuang();
        public TuMen tuMen = new TuMen();
        public TuQiao tuQiao = new TuQiao();
        public QiaoGang qiaoGang = new QiaoGang();
        public QingBo qingBo = new QingBo();
        public LangJia langJia = new LangJia();
        public GuangHua guangHua = new GuangHua();
        public NanBei nanBei = new NanBei();
        public FangQiao1 fangQiao1 = new FangQiao1();
        public FangQiao2 fangQiao2 = new FangQiao2();

        public CtrlFun()
        {
            //GetData();
           // TagNameEntity.Step = 0;
        }
        /// <summary>
        /// 读取配置
        /// </summary>
        private void ReadSetting()
        {

        }
        /// <summary>
        /// 获取实时数据
        /// </summary>
        public void GetData()
        {
            string connectString = $@"Data Source=192.168.0.89;Initial Catalog=Runtime;User ID=sa;Password=abc123!@#";
            string cmdsql = $@"SELECT v_Live.TagName , vValue 
                            FROM v_Live                           
                            LEFT JOIN AnalogTag ON AnalogTag.TagName =v_Live.TagName
                            LEFT JOIN EngineeringUnit ON AnalogTag.EUKey = EngineeringUnit.EUKey
                            LEFT JOIN QualityMap ON QualityMap.QualityDetail = v_Live.QualityDetail
                            WHERE v_Live.TagName IN ('展览馆.压力',
                            '正府街.压力',
                            '调度.需水状态',
                            '调度.调度模式',
                            '水量预测.时间点用水',
                            '水六厂A.二期出厂水秒流量',
                            '水六厂A.三期出厂水瞬时流量',
                            '水六厂A.一期出厂水瞬时流量',
                            '水六厂B.2#出水累计流量H',
                            '水六厂B.1#出水累计流量H',
                            '水六厂C.出水瞬时流量',                    
                            'SAC_水六厂A.S产水水量设定',
                            'SAC_水六厂B.S产水水量设定',
                            'SAC_水六厂C.S产水水量设定',
                            '水六厂A.三期出厂水水位',
                            'SAC_水七厂.S产水水量设定',
                            'SAC_水七厂二期.S产水水量设定',
                            'SAC_水七厂.Su总供水瞬时流量',
                            'SAC_水七厂.S清水池液位',
                            'SAC_水二厂.S总出水瞬时流量',
                            'SAC_水二厂.S产水水量设定',
                            '水二厂.1#出水','水二厂.2#出水','水二厂.3#出水','水二厂.4#出水','水二厂.5#出水','水二厂.6#出水','水二厂.7#出水','水二厂.8#出水','水二厂.9#出水','水二厂.10#出水',
                            'SAC_水五厂.S出水瞬时流量','SAC_水五厂.S产水水量设定',
                            '水五厂.1#出水','水五厂.2#出水','水五厂.3#出水','水五厂.4#出水','水五厂.5#出水','水五厂.6#出水','水五厂.7#出水','水五厂.8#出水','水五厂.9#出水','水五厂.10#出水','水五厂.11#出水',
                            '塔子山加压站.1#泵状态','塔子山加压站.2#泵状态', '塔子山加压站.3#泵状态', '塔子山加压站.4#泵状态',       
                            'SAC_塔子山.S清水池每米容积','塔子山加压站.进水瞬时流量','塔子山加压站.出水瞬时流量','塔子山加压站.2#清水池水位','SAC_塔子山.S产水水量设定',
                            '凤凰.低区1#泵状态','凤凰.低区2#泵状态','凤凰.低区3#泵状态','凤凰.低区4#泵状态','凤凰.低区5#泵状态','凤凰.低区6#泵状态','凤凰.低区7#泵状态','凤凰.低区8#泵状态','凤凰.低区9#泵状态','凤凰.低区10#泵状态',
                            '凤凰.低区出水瞬时流量','凤凰.进水瞬时流量','SAC_凤凰.S清水池液位','SAC_凤凰.S清水池每米容积','SAC_凤凰.S产水水量设定',
                            'SAC_洪河.S清水池每米容积','洪河.进水瞬时流量','洪河.S出水瞬时流量','SAC_洪河.S清水池液位','SAC_洪河.S产水水量设定',
                            '洪河.低区泵1状态','洪河.低区泵2状态','洪河.低区泵3状态','洪河.低区泵4状态',
                            '方桥一期.A阀开启度','方桥一期.B阀开启度','方桥一期.前后压力差','方桥一期.阀后压力','方桥一期.阀前压力',
                            '方桥二期.A阀开启度','方桥二期.B阀开启度','方桥二期.前后压力差','方桥二期.阀后压力','方桥二期.阀前压力',
                            '光华.A阀开启度','光华.B阀开启度','光华.前后压力差','光华.阀后压力','光华.阀前压力',
                            '南北大道.A阀开启度','南北大道.B阀开启度','南北大道.前后压力差','南北大道.阀后压力','南北大道.阀前压力',
                            '郎家.1#调流阀开启度','郎家.2#调流阀开启度','郎家.前后压差','郎家.阀后压力','郎家.阀前压力',
                            '青杠.1#阀开启度','青杠.2#阀开启度','青杠.前后压差','青杠.阀后压力','青杠.阀前压力',
                            '清波.1#阀开启度','清波.2#阀开启度','清波.前后压差','清波.阀后压力','清波.阀前压力',
                            '土门.1#阀开启度','土门.2#阀开启度','土门.前后压差','土门.阀后压力','土门.阀前压力',
                            '土桥.1#阀开启度','土桥.2#阀开启度','土桥.前后压差','土桥.阀后压力','土桥.阀前压力')";
            try
            {
                SqlConnection sqlCnt = new SqlConnection(connectString);
                sqlCnt.Open();
                SqlCommand command = new SqlCommand(cmdsql, sqlCnt);
                var datas = command.ExecuteReader();
                if (datas.HasRows)
                {
                    waterFactory_2.RideState = new bool[10];
                    waterFactory_5.RideState = new bool[11];
                    tazishan.RideState = new bool[4];
                    hongHe.RideState = new bool[4];
                    fengHuang.RideState = new bool[10];
                    float six1 = 0f, six2 = 0, six3 = 0, six4_1 = 0, six4_2 = 0, six5 = 0;
                    float abilitya = 0, abilityb = 0, abilityc = 0;
                    float abilty71 = 0, abilty72 = 0;
                    while (datas.Read())
                    {
                        if (datas["TagName"].ToString() == "展览馆.压力")
                        {
                            tagNameEntity.ZhanLanGuan = (float)Math.Round(float.Parse(datas["vValue"].ToString()), 3);
                        }
                        else if (datas["TagName"].ToString() == "正府街.压力")
                        {
                            tagNameEntity.ZhengFuJie = (float)Math.Round(float.Parse(datas["vValue"].ToString()), 3);
                        }
                        else if (datas["TagName"].ToString() == "调度.需水状态")
                        {
                            tagNameEntity.TrendOfWater = (Trend)Enum.Parse(typeof(Trend), datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "调度.调度模式")
                        {
                            tagNameEntity.Dispacth = (DispacthMod)Enum.Parse(typeof(DispacthMod), datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水量预测.时间点用水")
                        {
                            tagNameEntity.UseWater_17 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂A.二期出厂水秒流量")
                        {
                            six2 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂A.三期出厂水瞬时流量")
                        {
                            six3 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂A.一期出厂水瞬时流量")
                        {
                            six1 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂B.2#出水累计流量H")
                        {
                            six4_2 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂B.1#出水累计流量H")
                        {
                            six4_1 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂C.出水瞬时流量")
                        {
                            six5 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水六厂A.S产水水量设定")
                        {
                            abilitya = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水六厂B.S产水水量设定")
                        {
                            abilityb = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水六厂C.S产水水量设定")
                        {
                            abilityc = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水六厂A.三期出厂水水位")
                        {
                            waterFactory_6.Pool3 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水七厂.S产水水量设定")
                        {
                            abilty71 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水七厂二期.S产水水量设定")
                        {
                            abilty72 = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水七厂.Su总供水瞬时流量")
                        {
                            waterFactory_7.RealSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水七厂.S清水池液位")
                        {
                            waterFactory_7.Pool = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水二厂.S总出水瞬时流量")
                        {
                            waterFactory_2.RealSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水二厂.S产水水量设定")
                        {
                            waterFactory_2.Ability = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水二厂.1#出水")
                        {
                            waterFactory_2.RideState[0] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.2#出水")
                        {
                            waterFactory_2.RideState[1] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.3#出水")
                        {
                            waterFactory_2.RideState[2] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.4#出水")
                        {
                            waterFactory_2.RideState[3] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.5#出水")
                        {
                            waterFactory_2.RideState[4] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.6#出水")
                        {
                            waterFactory_2.RideState[5] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.7#出水")
                        {
                            waterFactory_2.RideState[6] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.8#出水")
                        {
                            waterFactory_2.RideState[7] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.9#出水")
                        {
                            waterFactory_2.RideState[8] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水二厂.10#出水")
                        {
                            waterFactory_2.RideState[9] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "SAC_水五厂.S出水瞬时流量")
                        {
                            waterFactory_5.RealSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_水五厂.S产水水量设定")
                        {
                            waterFactory_5.Ability = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "水五厂.1#出水")
                        {
                            waterFactory_5.RideState[0] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.2#出水")
                        {
                            waterFactory_5.RideState[1] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.3#出水")
                        {
                            waterFactory_5.RideState[2] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.4#出水")
                        {
                            waterFactory_5.RideState[3] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.5#出水")
                        {
                            waterFactory_5.RideState[4] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.6#出水")
                        {
                            waterFactory_5.RideState[5] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.7#出水")
                        {
                            waterFactory_5.RideState[6] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.8#出水")
                        {
                            waterFactory_5.RideState[7] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.9#出水")
                        {
                            waterFactory_5.RideState[8] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.10#出水")
                        {
                            waterFactory_5.RideState[9] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "水五厂.11#出水")
                        {
                            waterFactory_5.RideState[10] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.1#泵状态")
                        {
                            tazishan.RideState[0] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.2#泵状态")
                        {
                            tazishan.RideState[1] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.3#泵状态")
                        {
                            tazishan.RideState[2] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.4#泵状态")
                        {
                            tazishan.RideState[3] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "SAC_塔子山.S清水池每米容积")
                        {
                            tazishan.Squat = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.进水瞬时流量")
                        {
                            tazishan.RealInSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.出水瞬时流量")
                        {
                            tazishan.RealOutSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "塔子山加压站.2#清水池水位")
                        {
                            tazishan.Pool = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_塔子山.S产水水量设定")
                        {
                            tazishan.Ability = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区1#泵状态")
                        {
                            fengHuang.RideState[0] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区2#泵状态")
                        {
                            fengHuang.RideState[1] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区3#泵状态")
                        {
                            fengHuang.RideState[2] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区4#泵状态")
                        {
                            fengHuang.RideState[3] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区5#泵状态")
                        {
                            fengHuang.RideState[4] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区6#泵状态")
                        {
                            fengHuang.RideState[5] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区7#泵状态")
                        {
                            fengHuang.RideState[6] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区8#泵状态")
                        {
                            fengHuang.RideState[7] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区9#泵状态")
                        {
                            fengHuang.RideState[8] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区10#泵状态")
                        {
                            fengHuang.RideState[9] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "凤凰.低区出水瞬时流量")
                        {
                            fengHuang.RealOutSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "凤凰.进水瞬时流量")
                        {
                            fengHuang.RealInSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_凤凰.S清水池液位")
                        {
                            fengHuang.Pool = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_凤凰.S清水池每米容积")
                        {
                            fengHuang.Squat = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_凤凰.S产水水量设定")
                        {
                            fengHuang.Ability = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_洪河.S清水池每米容积")
                        {
                            hongHe.Squat = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_洪河.S产水水量设定")
                        {
                            hongHe.Ability = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "洪河.进水瞬时流量")
                        {
                            hongHe.RealInSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "洪河.S出水瞬时流量")
                        {
                            hongHe.RealOutSpeed = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "SAC_洪河.S清水池液位")
                        {
                            hongHe.Pool = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "洪河.低区泵1状态")
                        {
                            hongHe.RideState[0] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "洪河.低区泵2状态")
                        {
                            hongHe.RideState[1] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "洪河.低区泵3状态")
                        {
                            hongHe.RideState[2] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "洪河.低区泵4状态")
                        {
                            hongHe.RideState[3] = int.Parse(datas["vValue"].ToString())==1?true:false;
                        }
                        else if (datas["TagName"].ToString() == "方桥一期.A阀开启度")
                        {
                            fangQiao1.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥一期.B阀开启度")
                        {
                            fangQiao1.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥一期.前后压力差")
                        {
                            fangQiao1.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥一期.阀后压力")
                        {
                            fangQiao1.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥一期.阀前压力")
                        {
                            fangQiao1.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥二期.A阀开启度")
                        {
                            fangQiao2.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥二期.B阀开启度")
                        {
                            fangQiao2.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥二期.前后压力差")
                        {
                            fangQiao2.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥二期.阀后压力")
                        {
                            fangQiao2.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "方桥二期.阀前压力")
                        {
                            fangQiao2.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "光华.A阀开启度")
                        {
                            guangHua.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "光华.B阀开启度")
                        {
                            guangHua.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "光华.前后压力差")
                        {
                            guangHua.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "光华.阀后压力")
                        {
                            guangHua.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "光华.阀前压力")
                        {
                            guangHua.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "郎家.1#调流阀开启度")
                        {
                            langJia.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "郎家.2#调流阀开启度")
                        {
                            langJia.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "郎家.前后压差")
                        {
                            langJia.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "郎家.阀后压力")
                        {
                            langJia.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "郎家.阀前压力")
                        {
                            langJia.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "青杠.1#阀开启度")
                        {
                            qiaoGang.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "青杠.2#阀开启度")
                        {
                            qiaoGang.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "青杠.前后压差")
                        {
                            qiaoGang.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "青杠.阀后压力")
                        {
                            qiaoGang.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "青杠.阀前压力")
                        {
                            qiaoGang.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "清波.1#阀开启度")
                        {
                            qingBo.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "清波.2#阀开启度")
                        {
                            qingBo.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "清波.前后压差")
                        {
                            qingBo.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "清波.阀后压力")
                        {
                            qingBo.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "清波.阀前压力")
                        {
                            qingBo.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土门.1#阀开启度")
                        {
                            tuMen.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土门.2#阀开启度")
                        {
                            tuMen.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土门.前后压差")
                        {
                            tuMen.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土门.阀后压力")
                        {
                            tuMen.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土门.阀前压力")
                        {
                            tuMen.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土桥.1#阀开启度")
                        {
                            tuQiao.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土桥.2#阀开启度")
                        {
                            tuQiao.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土桥.前后压差")
                        {
                            tuQiao.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土桥.阀后压力")
                        {
                            tuQiao.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "土桥.阀前压力")
                        {
                            tuQiao.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "南北大道.A阀开启度")
                        {
                            nanBei.Open_A = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "南北大道.B阀开启度")
                        {
                            nanBei.Open_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "南北大道.前后压力差")
                        {
                            nanBei.SubPressure = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "南北大道.阀后压力")
                        {
                            nanBei.Pressuer_B = float.Parse(datas["vValue"].ToString());
                        }
                        else if (datas["TagName"].ToString() == "南北大道.阀前压力")
                        {
                            nanBei.Pressure_A = float.Parse(datas["vValue"].ToString());
                        }
                    }
                    waterFactory_6.Ability = abilitya + abilityb + abilityc;
                    waterFactory_6.RealSpeed = six1 + six2 + six3 + six4_1 + six4_2 + six5;
                    waterFactory_7.Ability = abilty71 + abilty72;
                }
            }
            catch(Exception ex)
            {
                
            }
            // throw new NotImplementedException();
        }
        /// <summary>
        /// 统计车台开启数
        /// </summary>
        /// <param name="Obj"></param>
        /// <returns></returns>
        private int GetRideNum(bool[] Obj)
        {
            int num = 0;
            for (int i = 0; i < Obj.Length; i++)
            {
                if (Obj[i])
                {
                    num++;
                }
            }
            return num;
        }
        /// <summary>
        /// 计算目标水位时间
        /// </summary>
        /// <returns></returns>
        private float TagetTime()
        {
            if (DateTime.Now.Hour >= 23 || DateTime.Now.Hour < 6)
            {
                if (DateTime.Now.Hour < 6)
                {
                    return (5 - DateTime.Now.Hour) + (60 - DateTime.Now.Minute) / 60;
                }
                else
                {
                    return 6 + (60 - DateTime.Now.Minute) / 60;
                }
            }
            else if (DateTime.Now.Hour < 17)
            {
                int tem = DateTime.Now.Hour > 13 ? 17 : 13;
                return (tem - DateTime.Now.Hour) + (60 - DateTime.Now.Minute) / 60;
            }
            else if (DateTime.Now.Hour <= 20)
            {
                return (19 - DateTime.Now.Hour) + 0.5f + (60 - DateTime.Now.Minute) / 60;
            }
            else
                return 0;
        }
        /// <summary>
        /// 是否符合目标液位
        /// </summary>
        /// <param name="Water">对比的液位</param>
        /// <param name="min">液位区间小</param>
        /// <param name="max">液位区间大</param>
        /// <returns></returns>
        private int IsPoolComplete(float Water, float min, float max)
        {
            if (min >= -0.00001 && min <= 0.00001)
            {
                if(  Water >= max && Water <= max + 0.5f)
                {
                    return 2;
                }
                else if(Water<max)
                {
                    return 1;
                }
                else
                {
                    return 3;
                }
            }
            else
            {
                if( Water >= min && Water <= max)
                {
                    return 2;
                }
                else if (Water<min)
                {
                    return 1;
                }
                else
                {
                    return 3;
                }
            }
        }
        /// <summary>
        /// 执行步骤记录
        /// </summary>
        /// <param name="step"></param>
        /// <param name="inner">子步骤</param>
        /// <returns></returns>
        private bool Instep(Steps step)
        {
            string cntstr = $@"Data Source=192.168.0.86;Initial Catalog=Tabwater_dev_new;User ID=sa;Password=abc123!@#";
            string sqlstr = $@"update K_FlowChart set Remarks='{step.Remarks}',Run=1 where Id='{step.Id.ToLower()}'";
            try
            {
                SqlConnection sqlcnt = new SqlConnection(cntstr);
                sqlcnt.Open();
                SqlCommand sqlCommand = new SqlCommand(sqlstr, sqlcnt);
                sqlCommand.ExecuteNonQuery();
                sqlcnt.Close();
            }
            catch
            {
                
            }
            
            return true;
        }

        /// <summary>
        /// 每一步操作步骤记录
        /// </summary>
        public static List<Steps> StepRecord = new List<Steps>();
        
        /// <summary>
        /// 生成调度指令
        /// </summary>
        /// <returns></returns>
        public CommandOut Dispatch()
        {

            StepRecord.Clear();//清空步骤记录
            cmd2.Cmd = "";
            cmd2.CmdoutText = "";
            cmd2.TagName = "";
            cmd2.Value1 = null;
            cmd2.Value2 = null;
            CommandOut result = new CommandOut();
            //车台开启数
            int tazishanride = GetRideNum(tazishan.RideState);
            int hongheride = GetRideNum(hongHe.RideState);
            int fenghuangride = GetRideNum(fengHuang.RideState);
            int waterfactory2ride = GetRideNum(waterFactory_2.RideState);
            int waterfactory5ride = GetRideNum(waterFactory_5.RideState);
            //相近时间控制点液位
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed) * (TagetTime()) / tazishan.Squat;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed) * (TagetTime()) / hongHe.Squat;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed) * (TagetTime()) / fengHuang.Squat;

            if (tagNameEntity.Dispacth == DispacthMod.经济)//经济调度模式
            {
                if (tagNameEntity.TrendOfWater == Trend.上升 )
                {
                    Instep(new Steps() {Id= "D062C8C6-AF5B-48A2-A276-19379D642C8C", Remarks=null  });
                    if (TagNameEntity.Step<=1&&WaterSmart.Stepin)
                    {
                        return null;
                    }
                    if (((TagNameEntity.Step >= 2 && WaterSmart.Stepin)||!WaterSmart.Stepin)&&Instep(new Steps() { Id= "BC4397F4-A6FE-421A-AB87-99CF3E76B687", Remarks = "塔子山:" + tazishan.RealInSpeed.ToString() + ",凤凰:" + fengHuang.RealInSpeed.ToString() + ",洪河:" + hongHe.RealInSpeed.ToString() })&&(tazishan.RealInSpeed > 500 || hongHe.RealInSpeed > 500 || fengHuang.RealInSpeed > 500))//加压站进水
                    {
                         
                       
                        result = JiaYa(true, true);
                    }
                    else if (((TagNameEntity.Step >= 3 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "3552D0C2-2110-4A77-8373-08E181B3C99F", Remarks = "六厂负荷:" + Math.Round(waterFactory_6.RealSpeed / waterFactory_6.Ability, 2) + "%,七厂负荷:" + Math.Round(waterFactory_7.RealSpeed / waterFactory_7.Ability, 2) + "%" })&&(waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))//六七厂负荷未达100%
                    {
                         
                        
                        result = Ctrlstation(true);
                    }
                    else if (((TagNameEntity.Step >= 4 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "F013B35A-CBAE-483A-94F8-6F5A674CBD68", Remarks = "洪河:" + hongheride.ToString() + "/" + hongHe.Canopenridenum.ToString() + ",凤凰:" + fenghuangride.ToString() + "/" + fengHuang.Canopenridenum + ",塔子山:" + tazishanride.ToString() + "/" + tazishan.Canopenridenum.ToString() })&&(tazishan.RealOutSpeed <= tazishan.Ability-1500 || hongHe.RealOutSpeed <= hongHe.Ability-2500 || fengHuang.RealOutSpeed <= fengHuang.Ability-2500))//加压站开启车台
                    {
                        
                        
                        result = JiaYa(true, false);
                    }
                    else if (((TagNameEntity.Step >= 5 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "6FD92AC3-81CB-45A8-B41B-6D366D13CD95", Remarks = "六厂负荷:" + Math.Round(waterFactory_6.RealSpeed / waterFactory_6.Ability, 2) + "%,七厂负荷:" + Math.Round(waterFactory_7.RealSpeed / waterFactory_7.Ability, 2) + "%" })&&(waterFactory_6.RealSpeed <= waterFactory_6.Ability * 1.05f || waterFactory_7.Ability * 1.05f >= waterFactory_7.RealSpeed) )//六七厂负荷达100%
                    {
                         
                        
                        result = Ctrlstation(true);
                    }
                    else if (((TagNameEntity.Step >= 6 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "BD8CBCFC-FF8C-4B43-BAA4-F3230FCA1C51", Remarks = "五厂负荷:" + Math.Round(waterFactory_5.RealSpeed / waterFactory_5.Ability, 2) + "%,二厂负荷:" + Math.Round(waterFactory_2.RealSpeed / waterFactory_2.Ability, 2) + "%" })&&(waterFactory_2.RealSpeed+1000 < waterFactory_2.Ability || waterFactory_5.RealSpeed+1000 < waterFactory_5.Ability)) //二、五厂开车
                    {
                                               
                        result = Factory(true);
                    }
                    else 
                    {
                        Instep(new Steps() { Id = "F23D682D-9CDB-4A40-B84A-3EF86859E46A", Remarks = "" });
                        JiaYa(true,false);
                    }
                }
                else if (tagNameEntity.TrendOfWater == Trend.下降)
                {
                     Instep(new Steps() {Id= "2CA5DA41-5D68-43A9-A836-5005412D58CA", Remarks=null  });
                    if (TagNameEntity.Step < 1 && WaterSmart.Stepin)
                    {
                        return null;
                    }
                    if (((TagNameEntity.Step >= 2 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() {Id= "47E0217F-ED43-418A-9D28-F14874F5C8ED", Remarks = "开车数:凤凰:" + fenghuangride.ToString() + ",洪河:" + hongheride.ToString() + ",塔子山:" + tazishanride.ToString() })&&(tazishanride > 0 || fenghuangride > 0 || hongheride > 0))//加压站出水有车，优先关加压站车台
                    {
                        
                        
                        result = JiaYa(false, false);
                    }
                    else if (((TagNameEntity.Step >= 3 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "8578A271-7162-437A-AD94-EDF0DFB41863", Remarks = "六厂三期:" + waterFactory_6.Pool3.ToString() + "/3.5,七厂:" + waterFactory_7.Pool.ToString() + "/3.5,六厂负荷:" + Math.Round(waterFactory_5.RealSpeed / waterFactory_5.Ability, 2) + "%,七厂负荷:" + Math.Round(waterFactory_2.RealSpeed / waterFactory_2.Ability, 2) + "%" } )&&(waterFactory_6.Pool3 < 3.5 || waterFactory_7.Pool < 3.5)&&(waterFactory_6.RealSpeed>waterFactory_6.Ability||waterFactory_7.RealSpeed>waterFactory_7.Ability))
                    {
                         
                        
                        result = Ctrlstation(false);
                    }
                    else if (((TagNameEntity.Step >= 4 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() {Id= "3359AC52-EEF9-4BF6-B2CB-DCC7CF0080C0", Remarks = "二厂开启车台:" + waterfactory2ride.ToString() + "五厂开启:" + waterfactory5ride.ToString() + ",加压站补水" })&&(waterfactory2ride == 0 && waterfactory5ride == 0))//二、五厂出水有车，关加压站厂车台
                    {
                         
                        
                        result = JiaYa(false, false);
                    }
                    else if (((TagNameEntity.Step >= 5 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() { Id= "3359AC52-EEF9-4BF6-B2CB-DCC7CF0080C0", Remarks = "二厂车台:" + waterfactory2ride.ToString() + "五厂:" + waterfactory5ride.ToString() } )&&(waterfactory2ride > 0 || waterfactory5ride > 0) )//二、五厂出水有车，优先关二、五厂车台
                    {
                         
                        
                        if (tazishanride == 0 && fenghuangride == 0 && hongheride ==0 )
                        {
                            //StepRecord[StepRecord.Count - 1].Instep = new List<Steps>();
                            Instep(new Steps() { Id= "008B21CD-68AC-48D5-B3EB-449B36D3AB93", Remarks = "洪河:" + hongheyewei.ToString() + ",凤凰:" + fenghuangyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() } ) ;
                            if ( (2<=IsPoolComplete(tazishanyewei, tazishan.TargetPoolMin, tazishan.TargetPoolMax) || 2<=IsPoolComplete(hongheyewei, hongHe.TargetPoolMin, hongHe.TargetPoolMax) ||2<=IsPoolComplete(fenghuangyewei, fengHuang.TargetPoolMin, fengHuang.TargetPoolMax)))
                            {
                                if (TagNameEntity.Step >= 6 && WaterSmart.Stepin)
                                {
                                    return null;
                                }
                                result= Factory(false);
                                
                            }
                            else //液位不满足
                            {
                                float bushuilang = ((tazishan.TargetPoolMin>0.1?tazishan.TargetPoolMin:tazishan.TargetPoolMax) - tazishan.Pool) * tazishan.Squat + ((hongHe.TargetPoolMin>0.1?hongHe.TargetPoolMin:hongHe.TargetPoolMax) - hongHe.Pool) * hongHe.Squat + ((fengHuang.TargetPoolMin>0.1?fengHuang.TargetPoolMin:fengHuang.TargetPoolMax) - fengHuang.Pool) * fengHuang.Squat;
                                Instep(new Steps() { Id= "FCF832DB-5C6E-45B1-BA5C-43914150A233", Remarks = "还需补水:" + bushuilang.ToString() });
                                if ((waterFactory_6.Ability + waterFactory_7.Ability) * (17 - DateTime.Now.Hour - 1 + (60 - DateTime.Now.Minute) / 60) >= tagNameEntity.UseWater_17 + bushuilang)//六七厂满足需水量
                                {
                                    Instep(new Steps() { Id= "5292E0E8-A05E-4850-94FE-C23867A7DE33", Remarks=DateTime.Now.ToShortTimeString() });
                                    if (TagNameEntity.Step <= 6 && WaterSmart.Stepin)
                                    {
                                        return null;
                                    }
                                    if (DateTime.Now.Hour <= 14 && (waterfactory2ride > 0 || waterfactory5ride > 0))//关二五厂车台
                                    {
                                        result = Factory(false);
                                    }
                                    else if (DateTime.Now.Hour >= 14 && (waterfactory2ride == 0 || waterfactory5ride == 0))//关加压站车台
                                    {
                                        if (tazishanride > 0 || fenghuangride > 0 || hongheride > 0)
                                            result = JiaYa(false, false);
                                        else
                                            result = JiaYa(false, true);
                                    }
                                }
                                else //六七厂不满足需水量
                                {
                                    Instep(new Steps() { Id="", Remarks = DateTime.Now.ToShortTimeString() } );
                                    if (TagNameEntity.Step >= 6 && WaterSmart.Stepin)
                                    {
                                        return null;
                                    }
                                    if (tazishanride > 0 || hongheride > 0 || fenghuangride > 0)//关加压站车台
                                    {
                                        result = JiaYa(false, false);
                                    }
                                    else
                                    {
                                        if (!(2>IsPoolComplete(tazishanyewei, tazishan.TargetPoolMin, tazishan.TargetPoolMax) || 2>IsPoolComplete(hongheyewei, hongHe.TargetPoolMin, hongHe.TargetPoolMax) ||2> IsPoolComplete(fenghuangyewei, fengHuang.TargetPoolMin, fengHuang.TargetPoolMax)))
                                            result = JiaYa(false, true);
                                        else
                                            result = Factory(false);
                                    }
                                }
                            }
                        }
                    }
                    else if (((DateTime.Now.Hour >= 22 || DateTime.Now.Hour < 6) && tazishanride == 0 && hongheride == 0 && fenghuangride == 0)) //夜间加压站补水
                    {
                        Instep(new Steps() { Id="",Remarks= "夜间加压站补水" } );
                        if (TagNameEntity.Step >= 6 && WaterSmart.Stepin)
                        {
                            return null;
                        }
                        float bushuilang = (tazishan.TargetPoolMax - tazishan.Pool) * tazishan.Squat + (hongHe.TargetPoolMax - hongHe.Pool) * hongHe.Squat + (fengHuang.TargetPoolMax - fengHuang.Pool) * fengHuang.Squat;
                        float times = DateTime.Now.Hour > 22 ? (24 - DateTime.Now.Hour - 1 + (60 - DateTime.Now.Minute) / 60 + 6) : (5 - DateTime.Now.Hour + (60 - DateTime.Now.Minute) / 60);
                        if (tagNameEntity.UseWater_17 + bushuilang < (waterFactory_6.Ability + waterFactory_7.Ability) * times)//六七厂满足补水需求
                        {
                            Instep(new Steps() {Id="",Remarks= "六七厂满足补水需求" });
                            if (TagNameEntity.Step >= 7 && WaterSmart.Stepin)
                            {
                                return null;
                            }
                            if (waterfactory2ride > 0 || waterfactory5ride > 0)//二五厂关车
                                result = Factory(false);
                            else
                            {
                                result = JiaYa(false, true);
                            }
                        }
                        else//不满足补水需求
                        {
                            Instep(new Steps() { Id="", Remarks = "六七厂不满足补水需求" } );
                            if (TagNameEntity.Step >= 7 && WaterSmart.Stepin)
                            {
                                return null;
                            }
                            result = JiaYa(false, true);
                        }
                    }
                }
            }
            else if (tagNameEntity.Dispacth == DispacthMod.安全)//安全调度模式
            {
                if (((TagNameEntity.Step >= 2 && WaterSmart.Stepin) || !WaterSmart.Stepin)&&Instep(new Steps() {Id="",Remarks="瞬时流量大于供水能力,可以认为清水池水位下降,六厂三期水位:"+waterFactory_6.Pool3.ToString()+",七厂水位:"+waterFactory_7.Pool.ToString()+",六厂:"+waterFactory_6.RealSpeed.ToString()+"/"+waterFactory_6.Ability.ToString()+",七厂:"+waterFactory_7.RealSpeed.ToString()+"/"+waterFactory_7.Ability.ToString() } ) && (waterFactory_6.RealSpeed > waterFactory_6.Ability || waterFactory_7.RealSpeed > waterFactory_7.Ability) && (waterFactory_7.Pool <= 3.5 || waterFactory_6.Pool3 <= 3.5))//供水大于生产能力，水位为下降。
                {
                    result = Ctrlstation(false);
                    cmd2 = Factory(true);//第二条指令，二五厂开车
                }
                else if (((TagNameEntity.Step >= 2 && WaterSmart.Stepin) || !WaterSmart.Stepin) && Instep(new Steps() {Id="",Remarks="凤凰:"+GetRideNum(fengHuang.RideState).ToString()+",洪河:"+GetRideNum(hongHe.RideState).ToString()+",塔子山:"+GetRideNum(tazishan.RideState).ToString() } ) &&GetRideNum(fengHuang.RideState) + GetRideNum(hongHe.RideState) + GetRideNum(tazishan.RideState) > 0)//洪河加压站至少有一台车开启
                {
                    result = JiaYa(false, false);
                    cmd2 = Factory(true);//
                }
                else if (((TagNameEntity.Step >= 2 && WaterSmart.Stepin) || !WaterSmart.Stepin)  && GetRideNum(fengHuang.RideState) + GetRideNum(hongHe.RideState) + GetRideNum(tazishan.RideState) == 0)//加压站出水无车
                {
                    if (waterFactory_6.Pool3 >= 3.8 && waterFactory_7.Pool >= 4.8 && waterFactory_6.RealSpeed <= waterFactory_6.Ability && waterFactory_7.RealSpeed <= waterFactory_7.Ability)//
                    {
                        result = Ctrlstation(true);
                        cmd2 = JiaYa(false, true);
                    }
                    else if (waterFactory_6.Pool3 < 3.5 && waterFactory_7.Pool < 3.5 && waterFactory_6.RealSpeed <= waterFactory_6.Ability && waterFactory_7.RealSpeed <= waterFactory_7.Ability)
                    {
                        result = JiaYa(false, true);
                        cmd2 = Factory(true);
                    }
                }
                else if (fengHuang.Pool >= fengHuang.TargetPoolMax && tazishan.Pool >= tazishan.TargetPoolMax && hongHe.Pool >= hongHe.TargetPoolMax && (waterFactory_6.Pool3 < 3.5 || waterFactory_7.Pool < 3.5))
                {
                    result = Ctrlstation(false);
                    cmd2 = Factory(true);
                }
                else if (tagNameEntity.TrendOfWater == Trend.上升)
                {
                    if (waterfactory2ride == 0 && waterfactory5ride == 0)
                    {

                        if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && tazishan.Pool * 1.09f < 6 && hongHe.Pool * 1.09f < 8 && fengHuang.Pool * 1.09f < 8 && (waterFactory_6.Pool3 > 3.8 && waterFactory_7.Pool > 4.8 && waterFactory_7.RealSpeed < waterFactory_7.Ability && waterFactory_6.RealSpeed < waterFactory_6.Ability))
                        {
                            result = Ctrlstation(true);
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && tazishan.Pool * 1.09f >= 6 && hongHe.Pool * 1.09f >= 8 && fengHuang.Pool * 1.09f >= 8 && waterFactory_6.RealSpeed * 1.01f <= waterFactory_6.Ability && waterFactory_7.Ability >= waterFactory_7.RealSpeed * 1.01f)
                        {
                            result = Factory(true);
                            if (result == null)
                            {
                                if (waterFactory_7.RealSpeed < waterFactory_7.Ability * 1.09f || waterFactory_6.RealSpeed < waterFactory_6.Ability * 1.09f)
                                {
                                    result = Ctrlstation(true);
                                }
                            }
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && tazishan.Pool >= 5.4 && hongHe.Pool >= 7.2 && fengHuang.Pool >= 7.2 && waterFactory_6.RealSpeed >= waterFactory_6.Ability && waterFactory_7.RealSpeed >= waterFactory_7.Ability && waterFactory_7.RealSpeed < waterFactory_7.Ability * 1.05 && waterFactory_6.RealSpeed < waterFactory_6.Ability * 1.05)
                        {
                            result = JiaYa(true, true);
                            cmd2 = Factory(true);
                        }

                    }
                    else
                    {
                        if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && tazishan.Pool * 1.09f <= 6 && hongHe.Pool * 1.09f <= 8 && fengHuang.Pool * 1.09f <= 8 && waterFactory_2.RealSpeed < waterFactory_2.Ability && waterFactory_5.RealSpeed < waterFactory_5.Ability)
                        {
                            result = Factory(true);
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && tazishan.Pool * 1.09f <= 6 && hongHe.Pool * 1.09f <= 8 && fengHuang.Pool * 1.09f < 8 && waterFactory_2.RealSpeed < waterFactory_2.Ability && waterFactory_5.RealSpeed < waterFactory_5.Ability)
                        {
                            result = JiaYa(true, true);
                            cmd2 = Factory(true);
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed > 1000 && waterFactory_2.RealSpeed >= waterFactory_2.Ability && waterFactory_5.RealSpeed >= waterFactory_5.Ability)
                        {
                            result = JiaYa(true, true);
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed < 200 && waterFactory_2.RealSpeed < waterFactory_2.Ability && waterFactory_5.RealSpeed < waterFactory_5.Ability)
                        {
                            result = Factory(true);
                        }
                        else if (tazishan.RealInSpeed + hongHe.RealInSpeed + fengHuang.RealInSpeed < 200 && waterFactory_2.RealSpeed >= waterFactory_2.Ability && waterFactory_5.RealSpeed >= waterFactory_5.Ability)
                        {
                            result = JiaYa(true, false);
                        }
                        else if (waterFactory_6.Ability * 1.05f >= waterFactory_6.RealSpeed && waterFactory_7.Ability * 1.05f >= waterFactory_7.RealSpeed)//待修正（加压站持续出水符合要求？）
                        {
                            result = Ctrlstation(true);
                        }
                    }
                }
                else if (tagNameEntity.TrendOfWater == Trend.下降)
                {
                    if (waterFactory_6.RealSpeed >= waterFactory_6.Ability && waterFactory_7.RealSpeed >= waterFactory_7.Ability)
                    {
                        result = Ctrlstation(false);
                    }
                    else if (tazishanride + hongheride + fenghuangride >0)
                    {
                        result = JiaYa(false, false);
                    }
                    else if (tazishanride + hongheride + fenghuangride <= 0)
                    {
                        result = JiaYa(false, true);
                    }
                    else if (2>IsPoolComplete(tazishanyewei, tazishan.TargetPoolMin, tazishan.TargetPoolMax) && 2>IsPoolComplete(hongheyewei, hongHe.TargetPoolMin, hongHe.TargetPoolMax) && 2>IsPoolComplete(fenghuangyewei, fengHuang.TargetPoolMin, fengHuang.TargetPoolMax))
                    {
                        result = Ctrlstation(false);
                    }
                    else if (waterFactory_2.RealSpeed >= waterFactory_2.Ability && waterFactory_5.RealSpeed >= waterFactory_5.Ability)
                    {
                        result = Factory(false);
                    }
                    else if (waterfactory5ride + waterfactory2ride == 0)
                    {
                        result = Ctrlstation(false);
                    }

                }


            }
            else
            {

            }

            return result;
        }
        public static CommandOut cmd2 = new CommandOut();
        /// <summary>
        /// 获取非自动控制控流站的前后压差的字符串
        /// 单步执行显示
        /// </summary>
        /// <param name="ss">6 为六厂，其它则是七厂</param>
        /// <returns></returns>
        private string GetSubpress(int ss)
        {
            string tmp = "";
            if (ss == 6)
            {
                if (!tuMen.AutoCtrl)
                    tmp = tmp + "土门:" + tuMen.SubPressure.ToString();
                if (!tuQiao.AutoCtrl)
                    tmp = tmp + " 土桥:" + tuQiao.SubPressure.ToString();
                if (!qiaoGang.AutoCtrl)
                    tmp = tmp + " 青杠:" + qiaoGang.SubPressure.ToString();
                if (!langJia.AutoCtrl)
                    tmp = tmp + " 郎家:" + langJia.SubPressure.ToString();
            }
            else
            {
                if (!qingBo.AutoCtrl)
                    tmp = tmp + "清波:" + qingBo.SubPressure.ToString();
                if (!guangHua.AutoCtrl)
                    tmp = tmp + " 光华:" + guangHua.SubPressure.ToString();
                if (!nanBei.AutoCtrl)
                    tmp = tmp + " 南北:" + nanBei.SubPressure.ToString();
                if (!fangQiao1.AutoCtrl)
                    tmp = tmp + " 方桥一期:" + fangQiao1.SubPressure.ToString();
                if (!fangQiao2.AutoCtrl)
                    tmp = tmp + " 方桥二期:" + fangQiao2.SubPressure.ToString();
            }
            return tmp;
        }
        /// <summary>
        /// 开土门
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenTumen()
        {
            CommandOut result = new CommandOut();
            if (((((tuMen.Open_B + 5 > tuMen.Open_A && tuMen.Open_B < tuMen.Open_A) || tuMen.Open_B > tuMen.Open_A) && tuMen.ACtrl) || !tuMen.BCtrl) && tuMen.Open_A < 90)
            {
                result.CmdoutText = $@"土门控流站A阀从{tuMen.Open_A}调到{tuMen.Open_A + 10}";
                result.TagName = "土门控流站";
                result.Cmd = "A阀";
                result.Value1 = tuMen.Open_A;
                result.Value2 = tuMen.Open_A + 10;
            }
            else if (tuMen.BCtrl)
            {
                result.CmdoutText = $@"土门控流站B阀从{tuMen.Open_B}调到{tuMen.Open_B + 10}";
                result.TagName = "土门控流站";
                result.Cmd = "B阀";
                result.Value1 = tuMen.Open_B;
                result.Value2 = tuMen.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (tuMen.ACtrl & tuMen.BCtrl)
                {
                    Instep(new Steps() { Id = "0B282658-EEEC-4A5A-A08F-847289D79715", Remarks = "双阀运行" });
                }
                else if (tuMen.ACtrl | tuMen.BCtrl)
                {
                    Instep(new Steps() { Id = "67B885D7-D539-4CFB-A8D0-BC56D6B20293", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (tuMen.ACtrl & tuMen.BCtrl)
                {
                    Instep(new Steps() { Id = "22A11BF3-56BF-45DE-BBA8-BE5559424F50", Remarks = "双阀运行" });
                }
                else if (tuMen.ACtrl | tuMen.BCtrl)
                {
                    Instep(new Steps() { Id = "111685EC-36A5-434D-A34F-EEEC11D38358", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开土桥
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenTuqiao()
        {
            CommandOut result = new CommandOut();
            if (((((tuQiao.Open_B + 5 > tuQiao.Open_A && tuQiao.Open_B < tuQiao.Open_A) || tuQiao.Open_B > tuQiao.Open_A) && tuQiao.ACtrl) || !tuQiao.BCtrl) && tuQiao.Open_A < 90)
            {
                result.CmdoutText = $@"土桥控流站A阀从{tuQiao.Open_A}调到{tuQiao.Open_A + 10}";
                result.TagName = "土桥控流站";
                result.Cmd = "A阀";
                result.Value1 = tuQiao.Open_A;
                result.Value2 = tuQiao.Open_A + 10;
            }
            else if (tuQiao.BCtrl)
            {
                result.CmdoutText = $@"土桥控流站B阀从{tuQiao.Open_B}调到{tuQiao.Open_B + 10}";
                result.TagName = "土桥控流站";
                result.Cmd = "B阀";
                result.Value1 = tuQiao.Open_B;
                result.Value2 = tuQiao.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (tuQiao.ACtrl & tuQiao.BCtrl)
                {
                    Instep(new Steps() { Id = "0B282658-EEEC-4A5A-A08F-847289D79715", Remarks = "双阀运行" });
                }
                else if (tuQiao.ACtrl | tuQiao.BCtrl)
                {
                    Instep(new Steps() { Id = "67B885D7-D539-4CFB-A8D0-BC56D6B20293", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (tuQiao.ACtrl & tuQiao.BCtrl)
                {
                    Instep(new Steps() { Id = "22A11BF3-56BF-45DE-BBA8-BE5559424F50", Remarks = "双阀运行" });
                }
                else if (tuQiao.ACtrl | tuQiao.BCtrl)
                {
                    Instep(new Steps() { Id = "111685EC-36A5-434D-A34F-EEEC11D38358", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开青杠
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenQinggang()
        {
            CommandOut result = new CommandOut();
            if (((((qiaoGang.Open_B + 5 > qiaoGang.Open_A && qiaoGang.Open_B < qiaoGang.Open_A) || qiaoGang.Open_B > qiaoGang.Open_A) && qiaoGang.ACtrl) || !qiaoGang.BCtrl) && qiaoGang.Open_A < 90)
            {
                result.CmdoutText = $@"青杠控流站A阀从{qiaoGang.Open_A}调到{qiaoGang.Open_A + 10}";
                result.TagName = "青杠控流站";
                result.Cmd = "A阀";
                result.Value1 = qiaoGang.Open_A;
                result.Value2 = qiaoGang.Open_A + 10;
            }
            else if (qiaoGang.BCtrl)
            {
                result.CmdoutText = $@"青杠控流站B阀从{qiaoGang.Open_B}调到{qiaoGang.Open_B + 10}";
                result.TagName = "青杠控流站";
                result.Cmd = "B阀";
                result.Value1 = qiaoGang.Open_B;
                result.Value2 = qiaoGang.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (qiaoGang.ACtrl & qiaoGang.BCtrl)
                {
                    Instep(new Steps() { Id = "0B282658-EEEC-4A5A-A08F-847289D79715", Remarks = "双阀运行" });
                }
                else if (qiaoGang.ACtrl | qiaoGang.BCtrl)
                {
                    Instep(new Steps() { Id = "67B885D7-D539-4CFB-A8D0-BC56D6B20293", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (qiaoGang.ACtrl & qiaoGang.BCtrl)
                {
                    Instep(new Steps() { Id = "22A11BF3-56BF-45DE-BBA8-BE5559424F50", Remarks = "双阀运行" });
                }
                else if (qiaoGang.ACtrl | qiaoGang.BCtrl)
                {
                    Instep(new Steps() { Id = "111685EC-36A5-434D-A34F-EEEC11D38358", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开郎家
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenLiangjia()
        {
            CommandOut result = new CommandOut();
            if (((((langJia.Open_B + 5 > langJia.Open_A && langJia.Open_B < langJia.Open_A) || langJia.Open_B > langJia.Open_A) && langJia.ACtrl) || !langJia.BCtrl) && langJia.Open_A < 90)
            {
                result.CmdoutText = $@"郎家控流站A阀从{langJia.Open_A}调到{langJia.Open_A + 10}";
                result.TagName = "郎家控流站";
                result.Cmd = "A阀";
                result.Value1 = langJia.Open_A;
                result.Value2 = langJia.Open_A + 10;
            }
            else if (langJia.BCtrl)
            {
                result.CmdoutText = $@"郎家控流站B阀从{langJia.Open_B}调到{langJia.Open_B + 10}";
                result.TagName = "郎家控流站";
                result.Cmd = "B阀";
                result.Value1 = langJia.Open_B;
                result.Value2 = langJia.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (langJia.ACtrl & langJia.BCtrl)
                {
                    Instep(new Steps() { Id = "0B282658-EEEC-4A5A-A08F-847289D79715", Remarks = "双阀运行" });
                }
                else if (langJia.ACtrl | langJia.BCtrl)
                {
                    Instep(new Steps() { Id = "67B885D7-D539-4CFB-A8D0-BC56D6B20293", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (langJia.ACtrl & langJia.BCtrl)
                {
                    Instep(new Steps() { Id = "22A11BF3-56BF-45DE-BBA8-BE5559424F50", Remarks = "双阀运行" });
                }
                else if (langJia.ACtrl | langJia.BCtrl)
                {
                    Instep(new Steps() { Id = "111685EC-36A5-434D-A34F-EEEC11D38358", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开光华
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenGuanghua()
        {
            CommandOut result = new CommandOut();
            if (((guangHua.Open_B + 5 > guangHua.Open_A && guangHua.Open_B < guangHua.Open_A) || guangHua.Open_B > guangHua.Open_A) && (guangHua.ACtrl || !guangHua.BCtrl) && guangHua.Open_A < 90)
            {
                result.CmdoutText = $@"光华控流站A阀从{guangHua.Open_A}调到{guangHua.Open_A + 10}";
                result.TagName = "光华控流站";
                result.Cmd = "A阀";
                result.Value1 = guangHua.Open_A;
                result.Value2 = guangHua.Open_A + 10;
            }
            else if (guangHua.BCtrl)
            {
                result.CmdoutText = $@"光华控流站B阀从{guangHua.Open_B}调到{guangHua.Open_B + 10}";
                result.TagName = "光华控流站";
                result.Cmd = "B阀";
                result.Value1 = guangHua.Open_B;
                result.Value2 = guangHua.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (guangHua.ACtrl & guangHua.BCtrl)
                {
                    Instep(new Steps() { Id = "A8E8704C-6135-4569-9B6F-3E93C198E8C1", Remarks = "双阀运行" });
                }
                else if (guangHua.ACtrl | guangHua.BCtrl)
                {
                    Instep(new Steps() { Id = "C999FDF5-7A79-4BE1-80C3-78455C9D6B0D", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (guangHua.ACtrl & guangHua.BCtrl)
                {
                    Instep(new Steps() { Id = "4A933124-C900-4DCA-A03F-2410685CADEF", Remarks = "双阀运行" });
                }
                else if (guangHua.ACtrl | guangHua.BCtrl)
                {
                    Instep(new Steps() { Id = "FF1FC8EA-9218-49E7-AC81-7B5920351BDA", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开南北
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenNanbei()
        {
            CommandOut result = new CommandOut();
            if (((nanBei.Open_B + 5 > nanBei.Open_A && nanBei.Open_B < nanBei.Open_A) || nanBei.Open_B > nanBei.Open_A) && (nanBei.ACtrl || !nanBei.BCtrl) && nanBei.Open_A < 90)
            {
                result.CmdoutText = $@"南北大道A阀从{nanBei.Open_A}调到{nanBei.Open_A + 10}";
                result.TagName = "南北大道";
                result.Cmd = "A阀";
                result.Value1 = nanBei.Open_A;
                result.Value2 = nanBei.Open_A + 10;
            }
            else if (nanBei.BCtrl)
            {
                result.CmdoutText = $@"南北大道B阀从{nanBei.Open_B}调到{nanBei.Open_B + 10}";
                result.TagName = "南北大道";
                result.Cmd = "B阀";
                result.Value1 = nanBei.Open_B;
                result.Value2 = nanBei.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (nanBei.ACtrl & nanBei.BCtrl)
                {
                    Instep(new Steps() { Id = "A8E8704C-6135-4569-9B6F-3E93C198E8C1", Remarks = "双阀运行" });
                }
                else if (nanBei.ACtrl | nanBei.BCtrl)
                {
                    Instep(new Steps() { Id = "C999FDF5-7A79-4BE1-80C3-78455C9D6B0D", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (nanBei.ACtrl & nanBei.BCtrl)
                {
                    Instep(new Steps() { Id = "4A933124-C900-4DCA-A03F-2410685CADEF", Remarks = "双阀运行" });
                }
                else if (nanBei.ACtrl | nanBei.BCtrl)
                {
                    Instep(new Steps() { Id = "FF1FC8EA-9218-49E7-AC81-7B5920351BDA", Remarks = "单阀运行" });
                }
            }
            return result;
        }
         /// <summary>
         /// 开清波
         /// </summary>
         /// <returns></returns>
        private CommandOut OpenQingbo()
        {
            CommandOut result = new CommandOut();
            if (((qingBo.Open_B + 5 > qingBo.Open_A && qingBo.Open_B < qingBo.Open_A) || qingBo.Open_B > qingBo.Open_A) && (qingBo.ACtrl || !qingBo.BCtrl) && qingBo.Open_A < 90)
            {
                result.CmdoutText = $@"清波控流站A阀从{qingBo.Open_A}调到{qingBo.Open_A + 10}";
                result.TagName = "清波控流站";
                result.Cmd = "A阀";
                result.Value1 = qingBo.Open_A;
                result.Value2 = qingBo.Open_A + 10;
            }
            else if (qingBo.BCtrl)
            {
                result.CmdoutText = $@"清波控流站B阀从{qingBo.Open_B}调到{qingBo.Open_B + 10}";
                result.TagName = "清波控流站";
                result.Cmd = "B阀";
                result.Value1 = qingBo.Open_B;
                result.Value2 = qingBo.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (qingBo.ACtrl & qingBo.BCtrl)
                {
                    Instep(new Steps() { Id = "A8E8704C-6135-4569-9B6F-3E93C198E8C1", Remarks = "双阀运行" });
                }
                else if (qingBo.ACtrl | qingBo.BCtrl)
                {
                    Instep(new Steps() { Id = "C999FDF5-7A79-4BE1-80C3-78455C9D6B0D", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (qingBo.ACtrl & qingBo.BCtrl)
                {
                    Instep(new Steps() { Id = "4A933124-C900-4DCA-A03F-2410685CADEF", Remarks = "双阀运行" });
                }
                else if (qingBo.ACtrl | qingBo.BCtrl)
                {
                    Instep(new Steps() { Id = "FF1FC8EA-9218-49E7-AC81-7B5920351BDA", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 开方桥一期
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenFangqiao1()
        {
            CommandOut result = new CommandOut();
            if (((fangQiao1.Open_B + 5 > fangQiao1.Open_A && fangQiao1.Open_B < fangQiao1.Open_A) || fangQiao1.Open_B > fangQiao1.Open_A) && (fangQiao1.ACtrl || !fangQiao1.BCtrl) && fangQiao1.Open_A < 90)
            {
                result.CmdoutText = $@"方桥一期控流站1#阀从{fangQiao1.Open_A}调到{fangQiao1.Open_A + 10}";
                result.TagName = "方桥一期控流站";
                result.Cmd = "1#阀";
                result.Value1 = fangQiao1.Open_A;
                result.Value2 = fangQiao1.Open_A + 10;
            }
            else if (fangQiao1.BCtrl)
            {
                result.CmdoutText = $@"方桥一期控流站2#阀从{fangQiao1.Open_B}调到{fangQiao1.Open_B + 10}";
                result.TagName = "方桥一期控流站";
                result.Cmd = "2#阀";
                result.Value1 = fangQiao1.Open_B;
                result.Value2 = fangQiao1.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (fangQiao1.ACtrl & fangQiao1.BCtrl)
                {
                    Instep(new Steps() { Id = "A8E8704C-6135-4569-9B6F-3E93C198E8C1", Remarks = "双阀运行" });
                }
                else if (fangQiao1.ACtrl | fangQiao1.BCtrl)
                {
                    Instep(new Steps() { Id = "C999FDF5-7A79-4BE1-80C3-78455C9D6B0D", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (fangQiao1.ACtrl & fangQiao1.BCtrl)
                {
                    Instep(new Steps() { Id = "4A933124-C900-4DCA-A03F-2410685CADEF", Remarks = "双阀运行" });
                }
                else if (fangQiao1.ACtrl | fangQiao1.BCtrl)
                {
                    Instep(new Steps() { Id = "FF1FC8EA-9218-49E7-AC81-7B5920351BDA", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        ///开方桥二期
        /// </summary>
        /// <returns></returns>
        private CommandOut OpenFangqiao2()
        {
            CommandOut result = new CommandOut();
            if (((fangQiao2.Open_B + 5 > fangQiao2.Open_A && fangQiao2.Open_B < fangQiao2.Open_A) || fangQiao2.Open_B > fangQiao2.Open_A) && (fangQiao2.ACtrl || !fangQiao2.BCtrl) && fangQiao2.Open_A < 90)
            {
                result.CmdoutText = $@"方桥二期控流站3#阀从{fangQiao2.Open_A}调到{fangQiao2.Open_A + 10}";
                result.TagName = "方桥二期控流站";
                result.Cmd = "1#阀";
                result.Value1 = fangQiao2.Open_A;
                result.Value2 = fangQiao2.Open_A + 10;
            }
            else if (fangQiao2.BCtrl)
            {
                result.CmdoutText = $@"方桥二期控流站4#阀从{fangQiao2.Open_B}调到{fangQiao2.Open_B + 10}";
                result.TagName = "方桥二期控流站";
                result.Cmd = "2#阀";
                result.Value1 = fangQiao2.Open_B;
                result.Value2 = fangQiao2.Open_B + 10;
            }
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                if (fangQiao2.ACtrl & fangQiao2.BCtrl)
                {
                    Instep(new Steps() { Id = "A8E8704C-6135-4569-9B6F-3E93C198E8C1", Remarks = "双阀运行" });
                }
                else if (fangQiao2.ACtrl | fangQiao2.BCtrl)
                {
                    Instep(new Steps() { Id = "C999FDF5-7A79-4BE1-80C3-78455C9D6B0D", Remarks = "单阀运行" });
                }
            }
            else
            {
                if (fangQiao2.ACtrl & fangQiao2.BCtrl)
                {
                    Instep(new Steps() { Id = "4A933124-C900-4DCA-A03F-2410685CADEF", Remarks = "双阀运行" });
                }
                else if (fangQiao2.ACtrl | fangQiao2.BCtrl)
                {
                    Instep(new Steps() { Id = "FF1FC8EA-9218-49E7-AC81-7B5920351BDA", Remarks = "单阀运行" });
                }
            }
            return result;
        }
        /// <summary>
        /// 关土门
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseTumen()
        {
            CommandOut result = new CommandOut();
            if (((tuMen.Open_B + 10 <= tuMen.Open_A && tuMen.ACtrl) || !tuMen.BCtrl) && tuMen.Open_A > 10)
            {
                result.CmdoutText = $@"土门控流站A阀从{tuMen.Open_A}调到{tuMen.Open_A - 10}";
                result.TagName = "土门控流站";
                result.Cmd = "A阀";
                result.Value1 = tuMen.Open_A;
                result.Value2 = tuMen.Open_A - 10;
            }
            else if (tuMen.BCtrl && tuMen.Open_B > 10)
            {
                result.CmdoutText = $@"土门控流站B阀从{tuMen.Open_B}调到{tuMen.Open_B - 10}";
                result.TagName = "土门控流站";
                result.Cmd = "B阀";
                result.Value1 = tuMen.Open_B;
                result.Value2 = tuMen.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关土桥
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseTuqiao()
        {
            CommandOut result = new CommandOut();
            if (((tuQiao.Open_B + 10 <= tuQiao.Open_A && tuQiao.ACtrl) || !tuQiao.BCtrl) && tuQiao.Open_A > 10)
            {
                result.CmdoutText = $@"土桥控流站A阀从{tuQiao.Open_A}调到{tuQiao.Open_A - 10}";
                result.TagName = "土桥控流站";
                result.Cmd = "A阀";
                result.Value1 = tuQiao.Open_A;
                result.Value2 = tuQiao.Open_A - 10;
            }
            else if (tuQiao.BCtrl && tuQiao.Open_B > 10)
            {
                result.CmdoutText = $@"土桥控流站B阀从{tuQiao.Open_B}调到{tuQiao.Open_B - 10}";
                result.TagName = "土桥控流站";
                result.Cmd = "B阀";
                result.Value1 = tuQiao.Open_B;
                result.Value2 = tuQiao.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关青杠
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseQinggang()
        {
            CommandOut result = new CommandOut();
            if ((((qiaoGang.Open_B + 10 <= qiaoGang.Open_A) && qiaoGang.ACtrl) || !qiaoGang.BCtrl) && qiaoGang.Open_A > 10)
            {
                result.CmdoutText = $@"青杠控流站A阀从{qiaoGang.Open_A}调到{qiaoGang.Open_A - 10}";
                result.TagName = "青杠控流站";
                result.Cmd = "A阀";
                result.Value1 = qiaoGang.Open_A;
                result.Value2 = qiaoGang.Open_A - 10;
            }
            else if (qiaoGang.BCtrl && qiaoGang.Open_B > 10)
            {
                result.CmdoutText = $@"青杠控流站B阀从{qiaoGang.Open_B}调到{qiaoGang.Open_B - 10}";
                result.TagName = "青杠控流站";
                result.Cmd = "B阀";
                result.Value1 = qiaoGang.Open_B;
                result.Value2 = qiaoGang.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关郎家
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseLiangjia()
        {
            CommandOut result = new CommandOut();
            if ((((langJia.Open_B + 10 <= langJia.Open_A) && langJia.ACtrl) || !langJia.BCtrl) && langJia.Open_A > 10)
            {
                result.CmdoutText = $@"郎家控流站A阀从{langJia.Open_A}调到{langJia.Open_A - 10}";
                result.TagName = "郎家控流站";
                result.Cmd = "A阀";
                result.Value1 = langJia.Open_A;
                result.Value2 = langJia.Open_A - 10;
            }
            else if (langJia.BCtrl && langJia.Open_B > 10)
            {
                result.CmdoutText = $@"郎家控流站B阀从{langJia.Open_B}调到{langJia.Open_B - 10}";
                result.TagName = "郎家控流站";
                result.Cmd = "B阀";
                result.Value1 = langJia.Open_B;
                result.Value2 = langJia.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关光华
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseGuanghua()
        {
            CommandOut result = new CommandOut();
            if ((guangHua.Open_B + 10 <= guangHua.Open_A) && (guangHua.ACtrl || !guangHua.BCtrl) && guangHua.Open_A > 10)
            {
                result.CmdoutText = $@"光华控流站A阀从{guangHua.Open_A}调到{guangHua.Open_A - 10}";
                result.TagName = "光华控流站";
                result.Cmd = "A阀";
                result.Value1 = guangHua.Open_A;
                result.Value2 = guangHua.Open_A - 10;
            }
            else if (guangHua.BCtrl && guangHua.Open_B > 10)
            {
                result.CmdoutText = $@"光华控流站B阀从{guangHua.Open_B}调到{guangHua.Open_B - 10}";
                result.TagName = "光华控流站";
                result.Cmd = "B阀";
                result.Value1 = guangHua.Open_B;
                result.Value2 = guangHua.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关南北
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseNanbei()
        {
            CommandOut result = new CommandOut();
            if ((nanBei.Open_B + 10 <= nanBei.Open_A) && (nanBei.ACtrl || !nanBei.BCtrl) && nanBei.Open_A > 10)
            {
                result.CmdoutText = $@"南北大道A阀从{nanBei.Open_A}调到{nanBei.Open_A - 10}";
                result.TagName = "南北大道";
                result.Cmd = "A阀";
                result.Value1 = nanBei.Open_A;
                result.Value2 = nanBei.Open_A - 10;
            }
            else if (nanBei.BCtrl && nanBei.Open_B > 10)
            {
                result.CmdoutText = $@"南北大道B阀从{nanBei.Open_B}调到{nanBei.Open_B - 10}";
                result.TagName = "南北大道";
                result.Cmd = "B阀";
                result.Value1 = nanBei.Open_B;
                result.Value2 = nanBei.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关清波
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseQingbo()
        {
            CommandOut result = new CommandOut();
            if ((qingBo.Open_B + 10 <= qingBo.Open_A) && (qingBo.ACtrl || !qingBo.BCtrl) && qingBo.Open_A > 10)
            {
                result.CmdoutText = $@"清波控流站A阀从{qingBo.Open_A}调到{qingBo.Open_A - 10}";
                result.TagName = "清波控流站";
                result.Cmd = "A阀";
                result.Value1 = qingBo.Open_A;
                result.Value2 = qingBo.Open_A - 10;
            }
            else if (qingBo.BCtrl && qingBo.Open_B > 10)
            {
                result.CmdoutText = $@"清波控流站B阀从{qingBo.Open_B}调到{qingBo.Open_B - 10}";
                result.TagName = "清波控流站";
                result.Cmd = "B阀";
                result.Value1 = qingBo.Open_B;
                result.Value2 = qingBo.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关方桥一期
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseFangqiao1()
        {
            CommandOut result = new CommandOut();
            if ((fangQiao1.Open_B + 10 <= fangQiao1.Open_A) && (fangQiao1.ACtrl || !fangQiao1.BCtrl) && fangQiao1.Open_A > 10)
            {
                result.CmdoutText = $@"方桥一期控流站1#阀从{fangQiao1.Open_A}调到{fangQiao1.Open_A - 10}";
                result.TagName = "方桥一期控流站";
                result.Cmd = "1#阀";
                result.Value1 = fangQiao1.Open_A;
                result.Value2 = fangQiao1.Open_A - 10;
            }
            else if (fangQiao1.BCtrl && fangQiao1.Open_B > 10)
            {
                result.CmdoutText = $@"方桥一期控流站2#阀从{fangQiao1.Open_B}调到{fangQiao1.Open_B - 10}";
                result.TagName = "方桥一期控流站";
                result.Cmd = "2#阀";
                result.Value1 = fangQiao1.Open_B;
                result.Value2 = fangQiao1.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 关方桥二期
        /// </summary>
        /// <returns></returns>
        private CommandOut CloseFangqiao2()
        {
            CommandOut result = new CommandOut();
            if ((fangQiao2.Open_B + 10 < fangQiao2.Open_A) && (fangQiao2.ACtrl || !fangQiao2.BCtrl) && fangQiao2.Open_A > 10)
            {
                result.CmdoutText = $@"方桥二期控流站3#阀从{fangQiao2.Open_A}调到{fangQiao2.Open_A - 10}";
                result.TagName = "方桥二期控流站";
                result.Cmd = "1#阀";
                result.Value1 = fangQiao2.Open_A;
                result.Value2 = fangQiao2.Open_A - 10;
            }
            else if (fangQiao2.BCtrl && fangQiao2.Open_B > 10)
            {
                result.CmdoutText = $@"方桥二期控流站4#阀从{fangQiao2.Open_B}调到{fangQiao2.Open_B - 10}";
                result.TagName = "方桥二期控流站";
                result.Cmd = "2#阀";
                result.Value1 = fangQiao2.Open_B;
                result.Value2 = fangQiao2.Open_B - 10;
            }
            return result;
        }
        /// <summary>
        /// 增加六厂出水量
        /// </summary>
        /// <returns></returns>
        private CommandOut RiseSixFactory()
        {
            CommandOut result = new CommandOut();
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                Instep(new Steps() { Id = "92C13F9A-707F-4CA9-8F4D-575E88AAD182", Remarks = "单/双阀运行" });
            }
            else
            {
                Instep(new Steps() { Id = "32EF7367-5E71-434C-9CFB-1CDB86602675", Remarks = "单/双阀运行" });
            }

            if (!tuMen.AutoCtrl && ((!tuQiao.AutoCtrl && tuMen.SubPressure > tuQiao.SubPressure) || tuQiao.AutoCtrl) && ((!qiaoGang.AutoCtrl && tuMen.SubPressure > qiaoGang.SubPressure) || qiaoGang.AutoCtrl) && ((!langJia.AutoCtrl && tuMen.SubPressure > langJia.SubPressure) || langJia.AutoCtrl) && (tuMen.Open_A < 90 || tuMen.Open_B < 90))
            {
                result = OpenTumen();
            }
            else if (!tuQiao.AutoCtrl && ((!tuMen.AutoCtrl && tuQiao.SubPressure > tuMen.SubPressure) || tuMen.AutoCtrl) && ((!qiaoGang.AutoCtrl && tuQiao.SubPressure > qiaoGang.SubPressure) || qiaoGang.AutoCtrl) && ((!langJia.AutoCtrl && langJia.SubPressure < tuQiao.SubPressure) || langJia.AutoCtrl) && (tuQiao.Open_A < 90 || tuQiao.Open_B < 90))
            {
                result = OpenTuqiao();
            }
            else if (!qiaoGang.AutoCtrl && ((!tuQiao.AutoCtrl && tuQiao.SubPressure < qiaoGang.SubPressure) || tuQiao.AutoCtrl) && ((!tuMen.AutoCtrl && tuMen.SubPressure < qiaoGang.SubPressure) || tuMen.AutoCtrl) && ((!langJia.AutoCtrl && langJia.SubPressure < qiaoGang.SubPressure) || langJia.AutoCtrl) && (qiaoGang.Open_A > 90 || qiaoGang.Open_B < 90))
            {
                result = OpenQinggang();
            }
            else if (!langJia.AutoCtrl && (langJia.Open_A < 90 || langJia.Open_B < 90))
            {
                result = OpenLiangjia();
            }
            return result;
        }
        /// <summary>
        /// 增加七厂出水量
        /// </summary>
        /// <returns></returns>
        private CommandOut RiseupSevenFactory()
        {
            CommandOut result = new CommandOut();
            if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
            {
                Instep(new Steps() { Id = "1C122353-064C-4E53-86C3-85D45361C8F5", Remarks = "单/双阀运行" });
            }
            else
            {
                Instep(new Steps() { Id = "40C4F371-B406-472F-A331-F931FD14F0E2", Remarks = "单/双阀运行" });
            }
            if (!guangHua.AutoCtrl && ((!nanBei.AutoCtrl && nanBei.SubPressure < guangHua.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && qingBo.SubPressure < guangHua.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure < guangHua.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure < guangHua.SubPressure) || fangQiao2.AutoCtrl) && (guangHua.Open_A < 90 || guangHua.Open_B < 90))
            {
                result = OpenGuanghua();
            }
            else if (!nanBei.AutoCtrl && ((!guangHua.AutoCtrl && nanBei.SubPressure > guangHua.SubPressure) || guangHua.AutoCtrl) && ((!qingBo.AutoCtrl && qingBo.SubPressure < nanBei.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure < nanBei.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure < nanBei.SubPressure) || fangQiao2.AutoCtrl) && (nanBei.Open_A < 90 || nanBei.Open_B < 90))
            {
                result = OpenNanbei();
            }
            else if (!qingBo.AutoCtrl && ((!guangHua.AutoCtrl && qingBo.SubPressure > guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && qingBo.SubPressure > nanBei.SubPressure) || nanBei.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure < qingBo.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure < qingBo.SubPressure) || fangQiao2.AutoCtrl) && (qingBo.Open_A < 90 || qingBo.Open_B < 90))
            {
                result = OpenQingbo();
            }
            else if (!fangQiao1.AutoCtrl && ((!guangHua.AutoCtrl && fangQiao1.SubPressure > guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && fangQiao1.SubPressure > nanBei.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && fangQiao1.SubPressure > qingBo.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure < fangQiao1.SubPressure) || fangQiao2.AutoCtrl) && (fangQiao1.Open_A < 90 || fangQiao1.Open_B < 90))
            {
                result = OpenFangqiao1();
            }
            else if (!fangQiao2.AutoCtrl && ((!guangHua.AutoCtrl && fangQiao2.SubPressure > guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && fangQiao2.SubPressure > nanBei.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && fangQiao2.SubPressure > qingBo.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao2.SubPressure > fangQiao1.SubPressure) || fangQiao1.AutoCtrl) && (fangQiao2.Open_A < 90 || fangQiao2.Open_B < 90))
            {
                result = OpenFangqiao2();
            }
            return result;
        }
        /// <summary>
        /// 减小六厂出水量
        /// </summary>
        /// <returns></returns>
        private  CommandOut DrowdownSixFactory()
        {
            CommandOut result = new CommandOut();
            Instep(new Steps() {Id= "9C60C866-30F9-4496-882A-C1AA1B904F89",Remarks="" });
            if (!tuMen.AutoCtrl && ((!tuQiao.AutoCtrl && tuMen.SubPressure <= tuQiao.SubPressure) || tuQiao.AutoCtrl) && ((!qiaoGang.AutoCtrl && tuMen.SubPressure <= qiaoGang.SubPressure) || qiaoGang.AutoCtrl) && ((!langJia.AutoCtrl && tuMen.SubPressure <= langJia.SubPressure) || langJia.AutoCtrl) && (tuMen.Open_A > 10 || tuMen.Open_B > 10))
            {
                result = CloseTumen();
            }
            else if (!tuQiao.AutoCtrl && ((!tuMen.AutoCtrl && tuQiao.SubPressure <= tuMen.SubPressure) || tuMen.AutoCtrl) && ((!qiaoGang.AutoCtrl && tuQiao.SubPressure <= qiaoGang.SubPressure) || qiaoGang.AutoCtrl) && ((!langJia.AutoCtrl && langJia.SubPressure >= tuQiao.SubPressure) || langJia.AutoCtrl) && (tuQiao.Open_A > 10 || tuQiao.Open_B > 10))
            {
                result = CloseTuqiao();
            }
            else if (!qiaoGang.AutoCtrl && ((!tuQiao.AutoCtrl && tuQiao.SubPressure > qiaoGang.SubPressure) || tuQiao.AutoCtrl) && ((!tuMen.AutoCtrl && tuMen.SubPressure > qiaoGang.SubPressure) || tuMen.AutoCtrl) && ((!langJia.AutoCtrl && langJia.SubPressure > qiaoGang.SubPressure) || langJia.AutoCtrl) && (qiaoGang.Open_A > 10 || qiaoGang.Open_B > 10))
            {
                result = CloseQinggang();
            }
            else if (!langJia.AutoCtrl && (langJia.Open_A > 10 || langJia.Open_B > 10))
            {
                result = CloseLiangjia();
            }
            Instep(new Steps() { Id = "4C936802-708A-4D13-98FE-B9347017C957", Remarks = result.CmdoutText });
            return result;
        }
        /// <summary>
        /// 关闭七厂控流站阀门
        /// </summary>
        /// <returns></returns>
        private CommandOut DrowdownSenvenFactory()
        {
            CommandOut result = new CommandOut();
            Instep(new Steps() { Id = "DC9209EC-F224-412D-9EF7-3104C14715E1", Remarks = "" });
            if (!guangHua.AutoCtrl && ((!nanBei.AutoCtrl && nanBei.SubPressure > guangHua.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && qingBo.SubPressure > guangHua.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure > guangHua.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure > guangHua.SubPressure) || fangQiao2.AutoCtrl) && (guangHua.Open_A > 10 || guangHua.Open_B > 10))
            {
                result = CloseGuanghua();
            }
            else if (!nanBei.AutoCtrl && ((!guangHua.AutoCtrl && nanBei.SubPressure < guangHua.SubPressure) || guangHua.AutoCtrl) && ((!qingBo.AutoCtrl && qingBo.SubPressure > nanBei.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure > nanBei.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure > nanBei.SubPressure) || fangQiao2.AutoCtrl) && (nanBei.Open_A > 10 || nanBei.Open_B > 10))
            {
                result = CloseNanbei();
            }
            else if (!qingBo.AutoCtrl && ((!guangHua.AutoCtrl && qingBo.SubPressure < guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && qingBo.SubPressure < nanBei.SubPressure) || nanBei.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao1.SubPressure < qingBo.SubPressure) || fangQiao1.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure > qingBo.SubPressure) || fangQiao2.AutoCtrl) && (qingBo.Open_A > 10 || qingBo.Open_B > 10))
            {
                result = CloseQingbo();
            }
            else if (!fangQiao1.AutoCtrl && ((!guangHua.AutoCtrl && fangQiao1.SubPressure < guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && fangQiao1.SubPressure < nanBei.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && fangQiao1.SubPressure < qingBo.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao2.AutoCtrl && fangQiao2.SubPressure > fangQiao1.SubPressure) || fangQiao2.AutoCtrl) && (fangQiao1.Open_A > 10 || fangQiao1.Open_B > 10))
            {
                result = CloseFangqiao1();
            }
            else if (!fangQiao2.AutoCtrl && ((!guangHua.AutoCtrl && fangQiao2.SubPressure < guangHua.SubPressure) || guangHua.AutoCtrl) && ((!nanBei.AutoCtrl && fangQiao2.SubPressure < nanBei.SubPressure) || nanBei.AutoCtrl) && ((!qingBo.AutoCtrl && fangQiao2.SubPressure < qingBo.SubPressure) || qingBo.AutoCtrl) && ((!fangQiao1.AutoCtrl && fangQiao2.SubPressure < fangQiao1.SubPressure) || fangQiao1.AutoCtrl) && (fangQiao2.Open_A > 10 || fangQiao2.Open_B > 10))
            {
                result = CloseFangqiao2();
            }
            Instep(new Steps() { Id = "FAB0041F-7E56-4390-BE18-5CF050E6AAE2", Remarks = result.CmdoutText });
            return result;
        }

        /// <summary>
        /// 控流站指令
        /// 调节六、七厂
        /// </summary>
        /// <returns></returns>
        public CommandOut Ctrlstation(bool up)
        {
            //StepRecord[StepRecord.Count - 1].Instep = new List<Steps>();
            CommandOut result = new CommandOut();
            
            if (TagNameEntity.Step ==4 || TagNameEntity.Step==6 && WaterSmart.Stepin)
            {
                return null;
            }
            if (up)
            {
                //8A851D40-54F5-4D07-9E11-F7304275650F
                if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
                {
                    Instep(new Steps() { Id = "8A851D40-54F5-4D07-9E11-F7304275650F", Remarks = "六厂" + Math.Round(waterFactory_6.RealSpeed / waterFactory_6.Ability, 2).ToString() + "%,七厂" + Math.Round(waterFactory_7.RealSpeed / waterFactory_7.Ability, 2).ToString() + "%" });
                }
                else
                {
                    Instep(new Steps() { Id = "D3DF7464-11D3-4E03-845F-F6ABB1834FE6", Remarks = "六厂" + Math.Round(waterFactory_6.RealSpeed / waterFactory_6.Ability, 2).ToString() + "%,七厂" + Math.Round(waterFactory_7.RealSpeed / waterFactory_7.Ability, 2).ToString() + "%" });
                }
                if ((waterFactory_6.RealSpeed / waterFactory_6.Ability < waterFactory_7.RealSpeed / waterFactory_7.Ability) || !(qingBo.AutoCtrl || nanBei.AutoCtrl || guangHua.AutoCtrl || fangQiao1.AutoCtrl || fangQiao2.AutoCtrl))//六厂负荷小于七厂或者七厂全部不用发指令，生成六厂指令
                {
                    if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
                    {
                        Instep(new Steps() { Id = "19ED0629-617D-4C92-8910-B834D2FC0486", Remarks = GetSubpress(6) });
                    }
                    else
                    {
                        Instep(new Steps() { Id = "A9D43A07-A7BC-4899-A74C-839E44372A2E", Remarks = GetSubpress(6) });
                    }
                    result = RiseSixFactory();
                }
                else//生成七厂指令
                {
                    if ((waterFactory_6.RealSpeed < waterFactory_6.Ability || waterFactory_7.Ability > waterFactory_7.RealSpeed))
                    { 
                        Instep(new Steps() { Id = "E6B7C8C7-4C11-43D2-B891-0142BEBAA82B", Remarks = GetSubpress(7) });
                    }
                    else
                    {
                        Instep(new Steps() { Id = "F5934FF0-9A08-40EA-AE54-E94DF8C37D04", Remarks = GetSubpress(7) });
                    }
                    result = RiseupSevenFactory();
                }
            }
            else
            {
                Instep(new Steps() { Id = "147008C1-0FEA-4AC6-A4EB-8C9E8A32E9C8", Remarks = GetSubpress(6) });
                if ((waterFactory_6.RealSpeed / waterFactory_6.Ability > waterFactory_7.RealSpeed / waterFactory_7.Ability) || !(qingBo.AutoCtrl || nanBei.AutoCtrl || guangHua.AutoCtrl || fangQiao1.AutoCtrl || fangQiao2.AutoCtrl))//六厂负荷小于七厂或者七厂全部不用发指令，生成六厂指令
                {
                    Instep(new Steps() { Id= "9C60C866-30F9-4496-882A-C1AA1B904F89", Remarks = GetSubpress(6) } );
                    result = DrowdownSixFactory();
                }
                else//生成七厂指令
                {
                    Instep(new Steps() {Id= "DC9209EC-F224-412D-9EF7-3104C14715E1", Remarks = GetSubpress(7) });
                    result = DrowdownSenvenFactory();
                }
            }
            return result;
        }
        /// <summary>
        /// 二、五厂指令
        /// </summary>
        /// <returns></returns>
        public CommandOut Factory(bool up)
        {
            //if (StepRecord[StepRecord.Count - 1].Instep == null)
            //StepRecord[StepRecord.Count - 1].Instep = new List<Steps>();
            int bigride = 0;//水三厂开启的大车数量
            for (int i = 5; i < 10; i++)
            {
                if (waterFactory_2.RideState[i])
                    bigride++;
            }
            CommandOut result = new CommandOut();
           // Instep(new Steps() {step=1,StepNames="二五厂",Remarks="二厂开启"+GetRideNum(waterFactory_2.RideState).ToString()+",五厂开启"+GetRideNum(waterFactory_5.RideState).ToString() }, true);
            if (TagNameEntity.Step <= 2 && WaterSmart.Stepin)
            {
                return null;
            }
            if (up)
            {
                Instep(new Steps() { Id= "7626CD15-798A-4B2C-B047-D8065C7D3085", Remarks = "二厂开启" + GetRideNum(waterFactory_2.RideState).ToString() + ",五厂开启" + GetRideNum(waterFactory_5.RideState).ToString() } );
                if (tagNameEntity.ZhanLanGuan <= 0.295 && (GetRideNum(waterFactory_2.RideState) < 7 && bigride < 4))
                {
                    Instep(new Steps() {Id= "04E1FEE4-BB10-45A3-B7CA-557F004917DF", Remarks = "展馆压力:" + tagNameEntity.ZhanLanGuan.ToString() + "MPa" } );
                    result.CmdoutText = "水二厂开一台大车";
                    result.TagName = "水二厂";
                    result.Cmd = "开一台大车";
                    result.Value1 = null;
                    result.Value2 = null;

                }
                else if (tagNameEntity.ZhanLanGuan <= 0.30)
                {
                    Instep(new Steps() { Id= "C965430D-BFDF-4385-A04D-B99A7E129967", Remarks = "展馆压力:" + tagNameEntity.ZhanLanGuan.ToString() + "MPa" } );
                    if ((GetRideNum(waterFactory_2.RideState) < 7 && GetRideNum(waterFactory_2.RideState) - bigride < 3) && GetRideNum(waterFactory_2.RideState) <= GetRideNum(waterFactory_5.RideState))
                    {
                        Instep(new Steps() { Id = "FD27DD12-3839-4D70-9029-5E319F3B7D56", Remarks = "水二厂开一台小车" });
                        result.CmdoutText = "水二厂开一台小车";
                        result.TagName = "水二厂";
                        result.Cmd = "开一台小车";
                        result.Value1 = null;
                        result.Value2 = null;
                    }
                    else if (GetRideNum(waterFactory_5.RideState) < 8)
                    {
                        Instep(new Steps() { Id = "B8D052E4-3C06-4DFD-9D6D-9B109B034EE3", Remarks = "水五厂开一台车" });
                        result.CmdoutText = "水五厂开一台车";
                        result.TagName = "水五厂";
                        result.Cmd = "开一台车";
                        result.Value1 = null;
                        result.Value2 = null;
                    }
                }
            }
            else
            {
                Instep(new Steps() {Id="", Remarks = "二厂开启" + GetRideNum(waterFactory_2.RideState).ToString() + ",五厂开启" + GetRideNum(waterFactory_5.RideState).ToString() } );
                if (TagNameEntity.Step <= 2 && WaterSmart.Stepin)
                {
                    return null;
                }
                if (tagNameEntity.ZhanLanGuan >= 0.315 && (waterFactory_2.RideState[5] || waterFactory_2.RideState[9] || waterFactory_2.RideState[8] || waterFactory_2.RideState[7] || waterFactory_2.RideState[6]))
                {
                    Instep(new Steps() { Id="", Remarks = "展馆压力:" + tagNameEntity.ZhanLanGuan.ToString() + "MPa" } );
                    result.CmdoutText = "水二厂停一台大车";
                    result.TagName = "水二厂";
                    result.Cmd = "停一台大车";
                    result.Value1 = null;
                    result.Value2 = null;

                }
                else if (tagNameEntity.ZhanLanGuan >= 0.310)
                {
                    Instep(new Steps() { Id="", Remarks = "展馆压力:" + tagNameEntity.ZhanLanGuan.ToString() + "MPa" } );
                    if (waterFactory_2.RideState[0] || waterFactory_2.RideState[1] || waterFactory_2.RideState[2] || waterFactory_2.RideState[3] || waterFactory_2.RideState[4])
                    {
                        result.CmdoutText = "水二厂停一台小车";
                        result.TagName = "水二厂";
                        result.Cmd = "停一台小车";
                        result.Value1 = null;
                        result.Value2 = null;
                    }
                    else if (GetRideNum(waterFactory_5.RideState) > 0)
                    {
                        result.CmdoutText = "水五厂停一台车";
                        result.TagName = "水五厂";
                        result.Cmd = "停一台车";
                        result.Value1 = null;
                        result.Value2 = null;
                    }
                }
            }
            return result;
            //throw new NotImplementedException();
        }
        /// <summary>
        /// 加压站关进水
        /// </summary>
        /// <returns></returns>
        private CommandOut TrunOffWater()
        {
            CommandOut result = new CommandOut();
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed-(tazishan.RealInSpeed>1000?1000:0)) * (TagetTime()) / tazishan.Squat - tazishan.TargetPoolMax;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed- (hongHe.RealInSpeed > 1000 ? 1000 : 0)) * (TagetTime()) / hongHe.Squat - hongHe.TargetPoolMax;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed- (fengHuang.RealInSpeed > 1000 ? 1000 : 0)) * (TagetTime()) / fengHuang.Squat - fengHuang.TargetPoolMax;
           // Instep(new Steps() { Id="", Remarks = "凤凰:" + (fenghuangyewei+fengHuang.TargetPoolMax).ToString() + ",洪河:" + (hongheyewei+hongHe.TargetPoolMax).ToString() + ",塔子山:" + (tazishanyewei+tazishan.TargetPoolMax).ToString() });
            if (TagNameEntity.Step <= 4 && WaterSmart.Stepin)
            {
                return null;
            }
            if (Instep(new Steps() {Id= "3821142A-B41B-4FE9-A88D-552A1AB81B5D", Remarks= "凤凰:" + (fenghuangyewei + fengHuang.TargetPoolMax).ToString() + ",洪河:" + (hongheyewei + hongHe.TargetPoolMax).ToString() + ",塔子山:" + (tazishanyewei + tazishan.TargetPoolMax).ToString() })&& (fenghuangyewei >= tazishanyewei && fenghuangyewei >= hongheyewei && fengHuang.RealInSpeed > 500 && IsPoolComplete(fenghuangyewei+fengHuang.TargetPoolMax, fengHuang.TargetPoolMin, fengHuang.TargetPoolMax)>=2))
            {
                result.CmdoutText = $@"凤凰山加压站进水关至{(fengHuang.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(fengHuang.RealInSpeed - 1000.0f)))}";
                result.TagName = "凤凰山加压站";
                result.Cmd = "进水关至";
                result.Value1 = null;
                result.Value2 = fengHuang.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(fengHuang.RealInSpeed - 1000.0f));
                Instep(new Steps() { Id= "E2600AA5-9251-4A35-AC5E-95EBF01689D6",Remarks=result.CmdoutText });
            }
            else if (Instep(new Steps() { Id = "01B702CB-37F8-4DA9-BD36-E61F7774C438", Remarks = "凤凰:" + (fenghuangyewei + fengHuang.TargetPoolMax).ToString() + ",洪河:" + (hongheyewei + hongHe.TargetPoolMax).ToString() + ",塔子山:" + (tazishanyewei + tazishan.TargetPoolMax).ToString() }) && (tazishanyewei >= hongheyewei && tazishanyewei >= fenghuangyewei && tazishan.RealInSpeed > 500 && 2<=IsPoolComplete(tazishan.TargetPoolMax+tazishanyewei, tazishan.TargetPoolMin, tazishan.TargetPoolMax)))
            {
                result.CmdoutText = $@"塔子山加压站进水关至{(tazishan.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(tazishan.RealInSpeed - 1000.0f)))}";
                result.TagName = "塔子山加压站";
                result.Cmd = "进水关至";
                result.Value1 = null;
                result.Value2 = tazishan.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(tazishan.RealInSpeed - 1000.0f));
                Instep(new Steps() { Id = "09CF49ED-B53E-4206-AB76-F6B9A995E3C6", Remarks = result.CmdoutText });
            }
            else if (hongHe.RealInSpeed > 500 &&2<= IsPoolComplete(hongheyewei+hongHe.TargetPoolMax, hongHe.TargetPoolMin, hongHe.TargetPoolMax))
            {
                result.CmdoutText = $@"洪河加压站进水关至{(hongHe.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(hongHe.RealInSpeed - 1000.0f)))}";
                result.TagName = "洪河加压站";
                result.Cmd = "进水关至";
                result.Value1 = null;
                result.Value2 = hongHe.RealInSpeed - 1000 < 700 ? 0 : (float)(Math.Round(hongHe.RealInSpeed - 1000.0f));
                Instep(new Steps() { Id = "F19A5561-5495-4B37-9035-0CF51DDA10D6", Remarks = result.CmdoutText });
            }
            else
            {
               result= Ctrlstation(true);
            }
            return result;

        }
        /// <summary>
        /// 加压站开进水
        /// </summary>
        /// <returns></returns>
        private CommandOut TrunOnWater()
        {
            CommandOut result = new CommandOut();
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed+1000) * (TagetTime()) / tazishan.Squat - tazishan.TargetPoolMax;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed+1000) * (TagetTime()) / hongHe.Squat - hongHe.TargetPoolMax;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed+1000) * (TagetTime()) / fengHuang.Squat - fengHuang.TargetPoolMax;
            Instep(new Steps() { Id= "83B3A556-2469-4411-984C-98031ADAFAFD", Remarks = "开进水后各加压站液位与目标液位差值,凤凰:" + fenghuangyewei.ToString() + ",洪河:" + hongheyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() });
            if (TagNameEntity.Step <= 4 && WaterSmart.Stepin)
            {
                return null;
            }
            if (fenghuangyewei <= tazishanyewei && fenghuangyewei <= hongheyewei && fengHuang.Pool < 8)
            {
                result.CmdoutText = $@"凤凰山加压站进水开至{(fengHuang.RealInSpeed < 500 ? 1000 : (float)Math.Round(fengHuang.RealInSpeed + 1500))}";
                result.TagName = "凤凰山加压站";
                result.Cmd = "进水开至";
                result.Value1 = null;
                result.Value2 = fengHuang.RealInSpeed < 500 ? 1000 : (float)Math.Round(fengHuang.RealInSpeed + 1500);
                Instep(new Steps() { Id= "A013A3AC-3B2B-4C8C-9A54-ADC5369B8E44",Remarks=result.CmdoutText });
            }
            else if (Instep(new Steps() {Id= "6211681D-5ECA-4DA5-ACFC-DF7EC16E3A76" })&&(tazishanyewei <= fenghuangyewei && tazishanyewei <= hongheyewei && tazishan.Pool < 6))
            {
                result.CmdoutText = $@"塔子山加压站进水开至{(tazishan.RealInSpeed < 500 ? 1000 : (float)Math.Round(tazishan.RealInSpeed + 1500))}";
                result.TagName = "塔子山加压站";
                result.Cmd = "进水开至";
                result.Value1 = null;
                result.Value2 = tazishan.RealInSpeed < 500 ? 1000 : (float)Math.Round(tazishan.RealInSpeed + 1500);
                Instep(new Steps() { Id = "288D65BA-31F4-4DD0-9324-8D93C211BEB6", Remarks = result.CmdoutText });
            }
            else if (hongHe.Pool < 8)
            {
                result.CmdoutText = $@"洪河加压站进水开至{(hongHe.RealInSpeed < 500 ? 1000 : (float)Math.Round(hongHe.RealInSpeed + 1500))}";
                result.TagName = "洪河加压站";
                result.Cmd = "进水开至";
                result.Value1 = null;
                result.Value2 = hongHe.RealInSpeed < 500 ? 1000 : (float)Math.Round(hongHe.RealInSpeed + 1500);
                Instep(new Steps() { Id = "894EC2E4-B7AE-4288-AEBC-E1DC2DA68572", Remarks = result.CmdoutText });
            }

            return result;

        }
        /// <summary>
        /// 加压站开车台
        /// </summary>
        /// <returns></returns>
        private CommandOut TrunOnRide()
        {
            CommandOut result = new CommandOut();
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed-2500) * (TagetTime()) / tazishan.Squat - tazishan.TargetPoolMax;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed-2500) * (TagetTime()) / hongHe.Squat - hongHe.TargetPoolMax;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed-2500) * (TagetTime()) / fengHuang.Squat - fengHuang.TargetPoolMax;

            
            if (TagNameEntity.Step <= 4 && WaterSmart.Stepin)
            {
                return null;
            }
            if (Instep(new Steps() { Id = "515EC0B4-0856-4788-9238-E930DA068A22", Remarks = "凤凰:" + (fenghuangyewei + fengHuang.TargetPoolMax).ToString() + ",洪河:" + (hongheyewei + hongHe.TargetPoolMax).ToString() + ",塔子山:" + (tazishanyewei + tazishan.TargetPoolMax).ToString() })&&(fenghuangyewei >= tazishanyewei && fenghuangyewei >= hongheyewei && GetRideNum(fengHuang.RideState) < fengHuang.Canopenridenum))
            {
                Instep(new Steps() { Id = "990C110F-FF18-45C4-BBB6-8B6E976EA23E", Remarks = "凤凰开车" });
                result.CmdoutText = "凤凰山加压站开一台车";
                result.TagName = "凤凰山加压站";
                result.Cmd = "开一台车";
                result.Value1 = null;
                result.Value2 = null;
            }
            else if (Instep(new Steps() { Id = "4B4E8B46-076E-414E-9EFC-23DC8842C1F9", Remarks = "凤凰:" + (fenghuangyewei + fengHuang.TargetPoolMax).ToString() + ",洪河:" + (hongheyewei + hongHe.TargetPoolMax).ToString() + ",塔子山:" + (tazishanyewei + tazishan.TargetPoolMax).ToString() })&&(tazishanyewei >= fenghuangyewei && tazishanyewei >= hongheyewei && GetRideNum(tazishan.RideState) < tazishan.Canopenridenum))
            {
                //65A1102E-E558-44D0-A1B3-502FA9BB2E52
                if (Instep(new Steps() { Id = "65A1102E-E558-44D0-A1B3-502FA9BB2E52", Remarks = "展览馆压力"+ tagNameEntity.ZhanLanGuan.ToString() })&&(tazishan.RideState[3] && tagNameEntity.ZhanLanGuan < 0.298))
                {
                    //4798546B-907F-48A6-80F9-2344CB149054
                    Instep(new Steps() { Id = "4798546B-907F-48A6-80F9-2344CB149054", Remarks = "塔子山开小车" });
                    result.CmdoutText = "塔子山加压站开一台小车";
                    result.TagName = "塔子山加压站";
                    result.Cmd = "开一台小车";
                    result.Value1 = null;
                    result.Value2 = null;
                }
                else if (!(tazishan.RideState[0] || tazishan.RideState[1] || tazishan.RideState[2]))
                {
                    Instep(new Steps() { Id = "7DF5F143-E906-49E1-A920-8F383B14BFCF", Remarks = "塔子山开大车" });
                    result.CmdoutText = "塔子山加压站开一台大车";
                    result.TagName = "塔子山加压站";
                    result.Cmd = "开一台大车";
                    result.Value1 = null;
                    result.Value2 = null;
                }
            }
            else if (GetRideNum(hongHe.RideState) < hongHe.Canopenridenum)
            {
                //FE6A2F21-BE1F-4278-97B2-DDE78161EA0E
                Instep(new Steps() { Id = "FE6A2F21-BE1F-4278-97B2-DDE78161EA0E", Remarks = "凤凰开车" });
                result.CmdoutText = "洪河加压站开一台车";
                result.TagName = "洪河加压站";
                result.Cmd = "开一台车";
                result.Value1 = null;
                result.Value2 = null;
            }

            return result;

        }
        /// <summary>
        /// 加压站关车台
        /// </summary>
        /// <returns></returns>
        private CommandOut TrunOffRide()
        {
            CommandOut result = new CommandOut();
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed+(GetRideNum(tazishan.RideState)>0?1:0)*2000) * (TagetTime()) / tazishan.Squat - tazishan.TargetPoolMax;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed + (GetRideNum(hongHe.RideState) > 0 ? 1 : 0) * 2000) * (TagetTime()) / hongHe.Squat - hongHe.TargetPoolMax;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed + (GetRideNum(fengHuang.RideState) > 0 ? 1 : 0) * 2000) * (TagetTime()) / fengHuang.Squat - fengHuang.TargetPoolMax;
            Instep(new Steps() {Id= "CAEBC831-83EB-4D4D-B0E0-C672ACCA71C3", Remarks = "凤凰:" + fenghuangyewei.ToString() + ",洪河:" + hongheyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() } );
            if (TagNameEntity.Step <= 4 && WaterSmart.Stepin)
            {
                return null;
            }
            if (fenghuangyewei <= tazishanyewei && fenghuangyewei <= hongheyewei && GetRideNum(fengHuang.RideState) > 0)
            {
                result.CmdoutText = "凤凰山加压站停一台车";
                result.TagName = "凤凰山加压站";
                result.Cmd = "停一台车";
                result.Value1 = null;
                result.Value2 = null;
                Instep(new Steps() { Id = "E70F717E-C6B5-410D-BCEF-284819242D7F", Remarks = "" });
            }
            else if (tazishanyewei <= fenghuangyewei && tazishanyewei <= hongheyewei && GetRideNum(tazishan.RideState) > 0)
            {
                Instep(new Steps() {Id= "8EA8D7B6-9B66-46B5-B03F-908BD908372F",Remarks="" });
                if (tazishan.RideState[3] && tagNameEntity.ZhanLanGuan > 0.31 && tagNameEntity.ZhanLanGuan < 0.315)
                {
                    result.CmdoutText = "塔子山加压站停一台小车";
                    result.TagName = "塔子山加压站";
                    result.Cmd = "停一台小车";
                    result.Value1 = null;
                    result.Value2 = null;
                }
                else if ((tazishan.RideState[0] || tazishan.RideState[1] || tazishan.RideState[2]))
                {
                    result.CmdoutText = "塔子山加压站停一台大车";
                    result.TagName = "塔子山加压站";
                    result.Cmd = "停一台大车";
                    result.Value1 = null;
                    result.Value2 = null;
                }
            }
            else if (GetRideNum(hongHe.RideState) > 0)
            {
                result.CmdoutText = "洪河加压站停一台车";
                result.TagName = "洪河加压站";
                result.Cmd = "停一台车";
                result.Value1 = null;
                result.Value2 = null;
                Instep(new Steps() { Id = "9D388DFA-F3E6-4E5E-847E-61E37841E997", Remarks = "" });
            }

            return result;

        }
        /// <summary>
        /// 加压站指令
        /// Up:水量上长虹标志，In:进水状态标志
        /// </summary>
        /// <returns></returns>
        public CommandOut JiaYa(bool Up, bool In)
        {
            //StepRecord[StepRecord.Count - 1].Instep = new List<Steps>();
            CommandOut result = new CommandOut();
            float tazishanyewei = tazishan.Pool + (tazishan.RealInSpeed - tazishan.RealOutSpeed) * (TagetTime()) / tazishan.Squat - tazishan.TargetPoolMax;
            float hongheyewei = hongHe.Pool + (hongHe.RealInSpeed - hongHe.RealOutSpeed) * (TagetTime()) / hongHe.Squat - hongHe.TargetPoolMax;
            float fenghuangyewei = fengHuang.Pool + (fengHuang.RealInSpeed - fengHuang.RealOutSpeed) * (TagetTime()) / fengHuang.Squat - fengHuang.TargetPoolMax;
            if (Up)
            {
                if (In)
                {
                  // Instep(new Steps() {Id="",Remarks="按当前保持的情况，预计液位与标准目标液位差值:凤凰"+fenghuangyewei.ToString()+",洪河:"+hongheyewei.ToString()+",塔子山:"+tazishanyewei.ToString() } );
                    if (TagNameEntity.Step <= 3 && WaterSmart.Stepin)
                    {
                        return null;
                    }
                    result = TrunOffWater();
                }
                else
                {
                    Instep(new Steps() { Id= "F013B35A-CBAE-483A-94F8-6F5A674CBD68", Remarks = "按当前保持的情况，预计液位与最高液位比较差值:凤凰" + fenghuangyewei.ToString() + ",洪河:" + hongheyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() } );
                    if (TagNameEntity.Step <= 5 && WaterSmart.Stepin)
                    {
                        return null;
                    }
                    result = TrunOnRide();
                }
            }
            else
            {
                if (In)
                {
                    Instep(new Steps() { Id= "83B3A556-2469-4411-984C-98031ADAFAFD", Remarks = "按当前保持的情况，预计液位与最高液位比较差值:凤凰" + fenghuangyewei.ToString() + ",洪河:" + hongheyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() } );
                    if (TagNameEntity.Step <= 3 && WaterSmart.Stepin)
                    {
                        return null;
                    }
                    result = TrunOnWater();
                }
                else
                {
                   // Instep(new Steps() { Id="", Remarks = "按当前保持的情况，预计液位与最高液位比较差值:凤凰" + fenghuangyewei.ToString() + ",洪河:" + hongheyewei.ToString() + ",塔子山:" + tazishanyewei.ToString() } );
                    if (TagNameEntity.Step <= 3 && WaterSmart.Stepin)
                    {
                        return null;
                    }
                    result = TrunOffRide();
                }
            }
            return result;
        }
        /// <summary>
        /// 用户界面显示 
        /// </summary>
        /// <param name="command"></param>
        public void ThrowToScada(CommandOut command)
        {
            throw new NotImplementedException();
        }
    }
}
